mirror of
https://github.com/immich-app/immich.git
synced 2026-04-25 18:49:52 -04:00
Merge branch 'main' into fix/shared-link-nav
This commit is contained in:
commit
b9694d9b52
@ -4,7 +4,7 @@ import path from 'node:path';
|
||||
import { setTimeout as sleep } from 'node:timers/promises';
|
||||
import { describe, expect, it, MockedFunction, vi } from 'vitest';
|
||||
|
||||
import { Action, checkBulkUpload, defaults, getSupportedMediaTypes, Reason } from '@immich/sdk';
|
||||
import { AssetRejectReason, AssetUploadAction, checkBulkUpload, defaults, getSupportedMediaTypes } from '@immich/sdk';
|
||||
import createFetchMock from 'vitest-fetch-mock';
|
||||
|
||||
import {
|
||||
@ -120,7 +120,7 @@ describe('checkForDuplicates', () => {
|
||||
vi.mocked(checkBulkUpload).mockResolvedValue({
|
||||
results: [
|
||||
{
|
||||
action: Action.Accept,
|
||||
action: AssetUploadAction.Accept,
|
||||
id: testFilePath,
|
||||
},
|
||||
],
|
||||
@ -144,10 +144,10 @@ describe('checkForDuplicates', () => {
|
||||
vi.mocked(checkBulkUpload).mockResolvedValue({
|
||||
results: [
|
||||
{
|
||||
action: Action.Reject,
|
||||
action: AssetUploadAction.Reject,
|
||||
id: testFilePath,
|
||||
assetId: 'fc5621b1-86f6-44a1-9905-403e607df9f5',
|
||||
reason: Reason.Duplicate,
|
||||
reason: AssetRejectReason.Duplicate,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -167,7 +167,7 @@ describe('checkForDuplicates', () => {
|
||||
vi.mocked(checkBulkUpload).mockResolvedValue({
|
||||
results: [
|
||||
{
|
||||
action: Action.Accept,
|
||||
action: AssetUploadAction.Accept,
|
||||
id: testFilePath,
|
||||
},
|
||||
],
|
||||
@ -187,7 +187,7 @@ describe('checkForDuplicates', () => {
|
||||
mocked.mockResolvedValue({
|
||||
results: [
|
||||
{
|
||||
action: Action.Accept,
|
||||
action: AssetUploadAction.Accept,
|
||||
id: testFilePath,
|
||||
},
|
||||
],
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import {
|
||||
Action,
|
||||
AssetBulkUploadCheckItem,
|
||||
AssetBulkUploadCheckResult,
|
||||
AssetMediaResponseDto,
|
||||
AssetMediaStatus,
|
||||
AssetUploadAction,
|
||||
Permission,
|
||||
addAssetsToAlbum,
|
||||
checkBulkUpload,
|
||||
@ -234,7 +234,7 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
|
||||
const results = response.results as AssetBulkUploadCheckResults;
|
||||
|
||||
for (const { id: filepath, assetId, action } of results) {
|
||||
if (action === Action.Accept) {
|
||||
if (action === AssetUploadAction.Accept) {
|
||||
newFiles.push(filepath);
|
||||
} else {
|
||||
// rejects are always duplicates
|
||||
@ -404,8 +404,6 @@ const uploadFile = async (input: string, stats: Stats): Promise<AssetMediaRespon
|
||||
const { baseUrl, headers } = defaults;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('deviceAssetId', `${basename(input)}-${stats.size}`.replaceAll(/\s+/g, ''));
|
||||
formData.append('deviceId', 'CLI');
|
||||
formData.append('fileCreatedAt', stats.mtime.toISOString());
|
||||
formData.append('fileModifiedAt', stats.mtime.toISOString());
|
||||
formData.append('fileSize', String(stats.size));
|
||||
|
||||
@ -20,8 +20,6 @@ def upload(file):
|
||||
}
|
||||
|
||||
data = {
|
||||
'deviceAssetId': f'{file}-{stats.st_mtime}',
|
||||
'deviceId': 'python',
|
||||
'fileCreatedAt': datetime.fromtimestamp(stats.st_mtime),
|
||||
'fileModifiedAt': datetime.fromtimestamp(stats.st_mtime),
|
||||
'isFavorite': 'false',
|
||||
|
||||
@ -6,6 +6,8 @@ You can read more about the differences between storage template engine on and o
|
||||
|
||||
The admin user can set the template by using the template builder in the `Administration -> Settings -> Storage Template`. Immich provides a set of variables that you can use in constructing the template, along with additional custom text. If the template produces [multiple files with the same filename, they won't be overwritten](https://github.com/immich-app/immich/discussions/3324) as a sequence number is appended to the filename.
|
||||
|
||||
Date and time variables in storage templates are rendered in the server's local timezone.
|
||||
|
||||
```bash title="Default template"
|
||||
Year/Year-Month-Day/Filename.Extension
|
||||
```
|
||||
|
||||
@ -130,12 +130,11 @@ describe('/albums', () => {
|
||||
describe('GET /albums', () => {
|
||||
it("should not show other users' favorites", async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get(`/albums/${user1Albums[0].id}?withoutAssets=false`)
|
||||
.get(`/albums/${user1Albums[0].id}`)
|
||||
.set('Authorization', `Bearer ${user2.accessToken}`);
|
||||
expect(status).toEqual(200);
|
||||
expect(body).toEqual({
|
||||
...user1Albums[0],
|
||||
assets: [expect.objectContaining({ isFavorite: false })],
|
||||
contributorCounts: [{ userId: user1.userId, assetCount: 1 }],
|
||||
lastModifiedAssetTimestamp: expect.any(String),
|
||||
startDate: expect.any(String),
|
||||
@ -304,13 +303,12 @@ describe('/albums', () => {
|
||||
describe('GET /albums/:id', () => {
|
||||
it('should return album info for own album', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get(`/albums/${user1Albums[0].id}?withoutAssets=false`)
|
||||
.get(`/albums/${user1Albums[0].id}`)
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual({
|
||||
...user1Albums[0],
|
||||
assets: [expect.objectContaining({ id: user1Albums[0].assets[0].id })],
|
||||
contributorCounts: [{ userId: user1.userId, assetCount: 1 }],
|
||||
lastModifiedAssetTimestamp: expect.any(String),
|
||||
startDate: expect.any(String),
|
||||
@ -322,7 +320,7 @@ describe('/albums', () => {
|
||||
|
||||
it('should return album info for shared album (editor)', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get(`/albums/${user2Albums[0].id}?withoutAssets=false`)
|
||||
.get(`/albums/${user2Albums[0].id}`)
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
@ -331,14 +329,14 @@ describe('/albums', () => {
|
||||
|
||||
it('should return album info for shared album (viewer)', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get(`/albums/${user1Albums[3].id}?withoutAssets=false`)
|
||||
.get(`/albums/${user1Albums[3].id}`)
|
||||
.set('Authorization', `Bearer ${user2.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(body).toMatchObject({ id: user1Albums[3].id });
|
||||
});
|
||||
|
||||
it('should return album info with assets when withoutAssets is undefined', async () => {
|
||||
it('should return album info', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get(`/albums/${user1Albums[0].id}`)
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
@ -346,25 +344,6 @@ describe('/albums', () => {
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual({
|
||||
...user1Albums[0],
|
||||
assets: [expect.objectContaining({ id: user1Albums[0].assets[0].id })],
|
||||
contributorCounts: [{ userId: user1.userId, assetCount: 1 }],
|
||||
lastModifiedAssetTimestamp: expect.any(String),
|
||||
startDate: expect.any(String),
|
||||
endDate: expect.any(String),
|
||||
albumUsers: expect.any(Array),
|
||||
shared: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return album info without assets when withoutAssets is true', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get(`/albums/${user1Albums[0].id}?withoutAssets=true`)
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual({
|
||||
...user1Albums[0],
|
||||
assets: [],
|
||||
contributorCounts: [{ userId: user1.userId, assetCount: 1 }],
|
||||
assetCount: 1,
|
||||
lastModifiedAssetTimestamp: expect.any(String),
|
||||
@ -379,13 +358,12 @@ describe('/albums', () => {
|
||||
await utils.deleteAssets(user1.accessToken, [user1Asset2.id]);
|
||||
|
||||
const { status, body } = await request(app)
|
||||
.get(`/albums/${user2Albums[0].id}?withoutAssets=true`)
|
||||
.get(`/albums/${user2Albums[0].id}`)
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual({
|
||||
...user2Albums[0],
|
||||
assets: [],
|
||||
contributorCounts: [{ userId: user1.userId, assetCount: 1 }],
|
||||
assetCount: 1,
|
||||
lastModifiedAssetTimestamp: expect.any(String),
|
||||
@ -426,7 +404,6 @@ describe('/albums', () => {
|
||||
shared: false,
|
||||
albumUsers: [],
|
||||
hasSharedLink: false,
|
||||
assets: [],
|
||||
assetCount: 0,
|
||||
owner: expect.objectContaining({ email: user1.userEmail }),
|
||||
isActivityEnabled: true,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import {
|
||||
AssetMediaResponseDto,
|
||||
AssetMediaStatus,
|
||||
AssetResponseDto,
|
||||
AssetTypeEnum,
|
||||
AssetVisibility,
|
||||
getAssetInfo,
|
||||
@ -19,7 +18,7 @@ import { Socket } from 'socket.io-client';
|
||||
import { createUserDto, uuidDto } from 'src/fixtures';
|
||||
import { makeRandomImage } from 'src/generators';
|
||||
import { errorDto } from 'src/responses';
|
||||
import { app, asBearerAuth, tempDir, TEN_TIMES, testAssetDir, utils } from 'src/utils';
|
||||
import { app, asBearerAuth, tempDir, testAssetDir, utils } from 'src/utils';
|
||||
import request from 'supertest';
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
@ -95,8 +94,8 @@ describe('/asset', () => {
|
||||
utils.createAsset(user1.accessToken),
|
||||
utils.createAsset(user1.accessToken, {
|
||||
isFavorite: true,
|
||||
fileCreatedAt: yesterday.toISO(),
|
||||
fileModifiedAt: yesterday.toISO(),
|
||||
fileCreatedAt: yesterday.toUTC().toISO(),
|
||||
fileModifiedAt: yesterday.toUTC().toISO(),
|
||||
assetData: { filename: 'example.mp4' },
|
||||
}),
|
||||
utils.createAsset(user1.accessToken),
|
||||
@ -380,62 +379,12 @@ describe('/asset', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /assets/random', () => {
|
||||
beforeAll(async () => {
|
||||
await Promise.all([
|
||||
utils.createAsset(user1.accessToken),
|
||||
utils.createAsset(user1.accessToken),
|
||||
utils.createAsset(user1.accessToken),
|
||||
utils.createAsset(user1.accessToken),
|
||||
utils.createAsset(user1.accessToken),
|
||||
utils.createAsset(user1.accessToken),
|
||||
]);
|
||||
|
||||
await utils.waitForQueueFinish(admin.accessToken, 'thumbnailGeneration');
|
||||
});
|
||||
|
||||
it.each(TEN_TIMES)('should return 1 random assets', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get('/assets/random')
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
|
||||
const assets: AssetResponseDto[] = body;
|
||||
expect(assets.length).toBe(1);
|
||||
expect(assets[0].ownerId).toBe(user1.userId);
|
||||
});
|
||||
|
||||
it.each(TEN_TIMES)('should return 2 random assets', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get('/assets/random?count=2')
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
|
||||
const assets: AssetResponseDto[] = body;
|
||||
expect(assets.length).toBe(2);
|
||||
|
||||
for (const asset of assets) {
|
||||
expect(asset.ownerId).toBe(user1.userId);
|
||||
}
|
||||
});
|
||||
|
||||
it.skip('should return 1 asset if there are 10 assets in the database but user 2 only has 1', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.get('/assets/random')
|
||||
.set('Authorization', `Bearer ${user2.accessToken}`);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual([expect.objectContaining({ id: user2Assets[0].id })]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PUT /assets/:id', () => {
|
||||
it('should require access', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.put(`/assets/${user2Assets[0].id}`)
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||
.set('Authorization', `Bearer ${user1.accessToken}`)
|
||||
.send({});
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.noPermission);
|
||||
});
|
||||
@ -1142,8 +1091,6 @@ describe('/asset', () => {
|
||||
const { body, status } = await request(app)
|
||||
.post('/assets')
|
||||
.set('Authorization', `Bearer ${quotaUser.accessToken}`)
|
||||
.field('deviceAssetId', 'example-image')
|
||||
.field('deviceId', 'e2e')
|
||||
.field('fileCreatedAt', new Date().toISOString())
|
||||
.field('fileModifiedAt', new Date().toISOString())
|
||||
.attach('assetData', makeRandomImage(), 'example.jpg');
|
||||
@ -1160,8 +1107,6 @@ describe('/asset', () => {
|
||||
const { body, status } = await request(app)
|
||||
.post('/assets')
|
||||
.set('Authorization', `Bearer ${quotaUser.accessToken}`)
|
||||
.field('deviceAssetId', 'example-image')
|
||||
.field('deviceId', 'e2e')
|
||||
.field('fileCreatedAt', new Date().toISOString())
|
||||
.field('fileModifiedAt', new Date().toISOString())
|
||||
.attach('assetData', randomBytes(2014), 'example.jpg');
|
||||
@ -1215,29 +1160,4 @@ describe('/asset', () => {
|
||||
expect(video.checksum).toStrictEqual(checksum);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /assets/exist', () => {
|
||||
it('ignores invalid deviceAssetIds', async () => {
|
||||
const response = await utils.checkExistingAssets(user1.accessToken, {
|
||||
deviceId: 'test-assets-exist',
|
||||
deviceAssetIds: ['invalid', 'INVALID'],
|
||||
});
|
||||
|
||||
expect(response.existingIds).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('returns the IDs of existing assets', async () => {
|
||||
await utils.createAsset(user1.accessToken, {
|
||||
deviceId: 'test-assets-exist',
|
||||
deviceAssetId: 'test-asset-0',
|
||||
});
|
||||
|
||||
const response = await utils.checkExistingAssets(user1.accessToken, {
|
||||
deviceId: 'test-assets-exist',
|
||||
deviceAssetIds: ['test-asset-0'],
|
||||
});
|
||||
|
||||
expect(response.existingIds).toEqual(['test-asset-0']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -110,7 +110,7 @@ describe('/libraries', () => {
|
||||
});
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(["All importPaths's elements must be unique"]));
|
||||
expect(body).toEqual(errorDto.badRequest(['[importPaths] Array must have unique items']));
|
||||
});
|
||||
|
||||
it('should not create an external library with duplicate exclusion patterns', async () => {
|
||||
@ -125,7 +125,7 @@ describe('/libraries', () => {
|
||||
});
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(["All exclusionPatterns's elements must be unique"]));
|
||||
expect(body).toEqual(errorDto.badRequest(['[exclusionPatterns] Array must have unique items']));
|
||||
});
|
||||
});
|
||||
|
||||
@ -157,7 +157,7 @@ describe('/libraries', () => {
|
||||
.send({ name: '' });
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['name should not be empty']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[name] Too small: expected string to have >=1 characters']));
|
||||
});
|
||||
|
||||
it('should change the import paths', async () => {
|
||||
@ -181,7 +181,7 @@ describe('/libraries', () => {
|
||||
.send({ importPaths: [''] });
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['each value in importPaths should not be empty']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[importPaths] Array items must not be empty']));
|
||||
});
|
||||
|
||||
it('should reject duplicate import paths', async () => {
|
||||
@ -191,7 +191,7 @@ describe('/libraries', () => {
|
||||
.send({ importPaths: ['/path', '/path'] });
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(["All importPaths's elements must be unique"]));
|
||||
expect(body).toEqual(errorDto.badRequest(['[importPaths] Array must have unique items']));
|
||||
});
|
||||
|
||||
it('should change the exclusion pattern', async () => {
|
||||
@ -215,7 +215,7 @@ describe('/libraries', () => {
|
||||
.send({ exclusionPatterns: ['**/*.jpg', '**/*.jpg'] });
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(["All exclusionPatterns's elements must be unique"]));
|
||||
expect(body).toEqual(errorDto.badRequest(['[exclusionPatterns] Array must have unique items']));
|
||||
});
|
||||
|
||||
it('should reject an empty exclusion pattern', async () => {
|
||||
@ -225,7 +225,7 @@ describe('/libraries', () => {
|
||||
.send({ exclusionPatterns: [''] });
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['each value in exclusionPatterns should not be empty']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[exclusionPatterns] Array items must not be empty']));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ describe('/map', () => {
|
||||
.get('/map/reverse-geocode?lon=123')
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['lat must be a number between -90 and 90']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[lat] Invalid input: expected number, received NaN']));
|
||||
});
|
||||
|
||||
it('should throw an error if a lat is not a number', async () => {
|
||||
@ -117,7 +117,7 @@ describe('/map', () => {
|
||||
.get('/map/reverse-geocode?lat=abc&lon=123.456')
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['lat must be a number between -90 and 90']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[lat] Invalid input: expected number, received NaN']));
|
||||
});
|
||||
|
||||
it('should throw an error if a lat is out of range', async () => {
|
||||
@ -125,7 +125,7 @@ describe('/map', () => {
|
||||
.get('/map/reverse-geocode?lat=91&lon=123.456')
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['lat must be a number between -90 and 90']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[lat] Too big: expected number to be <=90']));
|
||||
});
|
||||
|
||||
it('should throw an error if a lon is not provided', async () => {
|
||||
@ -133,7 +133,7 @@ describe('/map', () => {
|
||||
.get('/map/reverse-geocode?lat=75')
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['lon must be a number between -180 and 180']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[lon] Invalid input: expected number, received NaN']));
|
||||
});
|
||||
|
||||
const reverseGeocodeTestCases = [
|
||||
|
||||
@ -101,7 +101,7 @@ describe(`/oauth`, () => {
|
||||
it(`should throw an error if a redirect uri is not provided`, async () => {
|
||||
const { status, body } = await request(app).post('/oauth/authorize').send({});
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['redirectUri must be a string', 'redirectUri should not be empty']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[redirectUri] Invalid input: expected string, received undefined']));
|
||||
});
|
||||
|
||||
it('should return a redirect uri', async () => {
|
||||
@ -123,13 +123,13 @@ describe(`/oauth`, () => {
|
||||
it(`should throw an error if a url is not provided`, async () => {
|
||||
const { status, body } = await request(app).post('/oauth/callback').send({});
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['url must be a string', 'url should not be empty']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[url] Invalid input: expected string, received undefined']));
|
||||
});
|
||||
|
||||
it(`should throw an error if the url is empty`, async () => {
|
||||
const { status, body } = await request(app).post('/oauth/callback').send({ url: '' });
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['url should not be empty']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[url] Too small: expected string to have >=1 characters']));
|
||||
});
|
||||
|
||||
it(`should throw an error if the state is not provided`, async () => {
|
||||
|
||||
@ -74,7 +74,6 @@ describe('/search', () => {
|
||||
const bytes = await readFile(join(testAssetDir, filename));
|
||||
assets.push(
|
||||
await utils.createAsset(admin.accessToken, {
|
||||
deviceAssetId: `test-${filename}`,
|
||||
assetData: { bytes, filename },
|
||||
...dto,
|
||||
}),
|
||||
|
||||
@ -243,9 +243,21 @@ describe('/shared-links', () => {
|
||||
});
|
||||
|
||||
it('should get data for correct password protected link', async () => {
|
||||
const response = await request(app)
|
||||
.post('/shared-links/login')
|
||||
.send({ password: 'foo' })
|
||||
.query({ key: linkWithPassword.key });
|
||||
|
||||
expect(response.status).toBe(201);
|
||||
|
||||
const cookies = response.get('Set-Cookie') ?? [];
|
||||
expect(cookies).toHaveLength(1);
|
||||
expect(cookies[0]).toContain('immich_shared_link_token');
|
||||
|
||||
const { status, body } = await request(app)
|
||||
.get('/shared-links/me')
|
||||
.query({ key: linkWithPassword.key, password: 'foo' });
|
||||
.query({ key: linkWithPassword.key })
|
||||
.set('Cookie', cookies);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual(
|
||||
|
||||
@ -309,7 +309,7 @@ describe('/tags', () => {
|
||||
.get(`/tags/${uuidDto.invalid}`)
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['id must be a UUID']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[id] Invalid UUID']));
|
||||
});
|
||||
|
||||
it('should get tag details', async () => {
|
||||
@ -427,7 +427,7 @@ describe('/tags', () => {
|
||||
.delete(`/tags/${uuidDto.invalid}`)
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['id must be a UUID']));
|
||||
expect(body).toEqual(errorDto.badRequest(['[id] Invalid UUID']));
|
||||
});
|
||||
|
||||
it('should delete a tag', async () => {
|
||||
|
||||
@ -287,7 +287,8 @@ describe('/admin/users', () => {
|
||||
it('should delete user', async () => {
|
||||
const { status, body } = await request(app)
|
||||
.delete(`/admin/users/${userToDelete.userId}`)
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`)
|
||||
.send({});
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(body).toMatchObject({
|
||||
|
||||
@ -178,7 +178,9 @@ describe('/users', () => {
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['download.archiveSize must be an integer number']));
|
||||
expect(body).toEqual(
|
||||
errorDto.badRequest(['[download.archiveSize] Invalid input: expected int, received number']),
|
||||
);
|
||||
});
|
||||
|
||||
it('should update download archive size', async () => {
|
||||
@ -204,7 +206,9 @@ describe('/users', () => {
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`);
|
||||
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest(['download.includeEmbeddedVideos must be a boolean value']));
|
||||
expect(body).toEqual(
|
||||
errorDto.badRequest(['[download.includeEmbeddedVideos] Invalid input: expected boolean, received number']),
|
||||
);
|
||||
});
|
||||
|
||||
it('should update download include embedded videos', async () => {
|
||||
|
||||
@ -16,8 +16,8 @@ test.describe('Duplicates Utility', () => {
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
[firstAsset, secondAsset] = await Promise.all([
|
||||
utils.createAsset(admin.accessToken, { deviceAssetId: 'duplicate-a' }),
|
||||
utils.createAsset(admin.accessToken, { deviceAssetId: 'duplicate-b' }),
|
||||
utils.createAsset(admin.accessToken, {}),
|
||||
utils.createAsset(admin.accessToken, {}),
|
||||
]);
|
||||
|
||||
await updateAssets(
|
||||
|
||||
@ -77,18 +77,4 @@ test.describe('Photo Viewer', () => {
|
||||
});
|
||||
expect(tagAtCenter).toBe('IMG');
|
||||
});
|
||||
|
||||
test('reloads photo when checksum changes', async ({ page }) => {
|
||||
await page.goto(`/photos/${asset.id}`);
|
||||
|
||||
const preview = page.getByTestId('preview').filter({ visible: true });
|
||||
await expect(preview).toHaveAttribute('src', /.+/);
|
||||
const initialSrc = await preview.getAttribute('src');
|
||||
|
||||
const websocketEvent = utils.waitForWebsocketEvent({ event: 'assetUpdate', id: asset.id });
|
||||
await utils.replaceAsset(admin.accessToken, asset.id);
|
||||
await websocketEvent;
|
||||
|
||||
await expect(preview).not.toHaveAttribute('src', initialSrc!);
|
||||
});
|
||||
});
|
||||
|
||||
@ -315,11 +315,9 @@ export function toAssetResponseDto(asset: MockTimelineAsset, owner?: UserRespons
|
||||
|
||||
return {
|
||||
id: asset.id,
|
||||
deviceAssetId: `device-${asset.id}`,
|
||||
ownerId: asset.ownerId,
|
||||
owner: owner || defaultOwner,
|
||||
libraryId: `library-${asset.ownerId}`,
|
||||
deviceId: `device-${asset.ownerId}`,
|
||||
type: asset.isVideo ? AssetTypeEnum.Video : AssetTypeEnum.Image,
|
||||
originalPath: `/original/${asset.id}.${asset.isVideo ? 'mp4' : 'jpg'}`,
|
||||
originalFileName: `${asset.id}.${asset.isVideo ? 'mp4' : 'jpg'}`,
|
||||
@ -429,7 +427,6 @@ export function getAlbum(
|
||||
hasSharedLink: false,
|
||||
isActivityEnabled: true,
|
||||
assetCount: albumAssets.length,
|
||||
assets: albumAssets,
|
||||
startDate: albumAssets.length > 0 ? albumAssets.at(-1)?.fileCreatedAt : undefined,
|
||||
endDate: albumAssets.length > 0 ? albumAssets[0].fileCreatedAt : undefined,
|
||||
lastModifiedAssetTimestamp: albumAssets.length > 0 ? albumAssets[0].fileCreatedAt : undefined,
|
||||
|
||||
@ -16,7 +16,6 @@ export const createMockStackAsset = (ownerId: string): AssetResponseDto => {
|
||||
const now = new Date().toISOString();
|
||||
return {
|
||||
id: assetId,
|
||||
deviceAssetId: `device-${assetId}`,
|
||||
ownerId,
|
||||
owner: {
|
||||
id: ownerId,
|
||||
@ -27,7 +26,6 @@ export const createMockStackAsset = (ownerId: string): AssetResponseDto => {
|
||||
avatarColor: 'blue' as never,
|
||||
},
|
||||
libraryId: `library-${ownerId}`,
|
||||
deviceId: `device-${ownerId}`,
|
||||
type: AssetTypeEnum.Image,
|
||||
originalPath: `/original/${assetId}.jpg`,
|
||||
originalFileName: `${assetId}.jpg`,
|
||||
@ -69,7 +67,7 @@ export const createMockStackAsset = (ownerId: string): AssetResponseDto => {
|
||||
tags: [],
|
||||
people: [],
|
||||
unassignedFaces: [],
|
||||
stack: null,
|
||||
stack: undefined,
|
||||
isOffline: false,
|
||||
hasMetadata: true,
|
||||
duplicateId: null,
|
||||
|
||||
@ -3,7 +3,6 @@ import {
|
||||
AssetMediaResponseDto,
|
||||
AssetResponseDto,
|
||||
AssetVisibility,
|
||||
CheckExistingAssetsDto,
|
||||
CreateAlbumDto,
|
||||
CreateLibraryDto,
|
||||
JobCreateDto,
|
||||
@ -20,7 +19,6 @@ import {
|
||||
UserAdminCreateDto,
|
||||
UserPreferencesUpdateDto,
|
||||
ValidateLibraryDto,
|
||||
checkExistingAssets,
|
||||
createAlbum,
|
||||
createApiKey,
|
||||
createJob,
|
||||
@ -343,8 +341,6 @@ export const utils = {
|
||||
},
|
||||
) => {
|
||||
const _dto = {
|
||||
deviceAssetId: 'test-1',
|
||||
deviceId: 'test',
|
||||
fileCreatedAt: new Date().toISOString(),
|
||||
fileModifiedAt: new Date().toISOString(),
|
||||
...dto,
|
||||
@ -375,40 +371,6 @@ export const utils = {
|
||||
return body as AssetMediaResponseDto;
|
||||
},
|
||||
|
||||
replaceAsset: async (
|
||||
accessToken: string,
|
||||
assetId: string,
|
||||
dto?: Partial<Omit<AssetMediaCreateDto, 'assetData'>> & { assetData?: FileData },
|
||||
) => {
|
||||
const _dto = {
|
||||
deviceAssetId: 'test-1',
|
||||
deviceId: 'test',
|
||||
fileCreatedAt: new Date().toISOString(),
|
||||
fileModifiedAt: new Date().toISOString(),
|
||||
...dto,
|
||||
};
|
||||
|
||||
const assetData = dto?.assetData?.bytes || makeRandomImage();
|
||||
const filename = dto?.assetData?.filename || 'example.png';
|
||||
|
||||
if (dto?.assetData?.bytes) {
|
||||
console.log(`Uploading ${filename}`);
|
||||
}
|
||||
|
||||
const builder = request(app)
|
||||
.put(`/assets/${assetId}/original`)
|
||||
.attach('assetData', assetData, filename)
|
||||
.set('Authorization', `Bearer ${accessToken}`);
|
||||
|
||||
for (const [key, value] of Object.entries(_dto)) {
|
||||
void builder.field(key, String(value));
|
||||
}
|
||||
|
||||
const { body } = await builder;
|
||||
|
||||
return body as AssetMediaResponseDto;
|
||||
},
|
||||
|
||||
createImageFile: (path: string) => {
|
||||
if (!existsSync(dirname(path))) {
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
@ -450,9 +412,6 @@ export const utils = {
|
||||
|
||||
getAssetInfo: (accessToken: string, id: string) => getAssetInfo({ id }, { headers: asBearerAuth(accessToken) }),
|
||||
|
||||
checkExistingAssets: (accessToken: string, checkExistingAssetsDto: CheckExistingAssetsDto) =>
|
||||
checkExistingAssets({ checkExistingAssetsDto }, { headers: asBearerAuth(accessToken) }),
|
||||
|
||||
searchAssets: async (accessToken: string, dto: MetadataSearchDto) => {
|
||||
return searchAssets({ metadataSearchDto: dto }, { headers: asBearerAuth(accessToken) });
|
||||
},
|
||||
|
||||
@ -1392,6 +1392,7 @@
|
||||
"light_theme": "Switch to light theme",
|
||||
"like": "Like",
|
||||
"like_deleted": "Like deleted",
|
||||
"link": "Link",
|
||||
"link_motion_video": "Link motion video",
|
||||
"link_to_docs": "For more information, refer to the <link>documentation</link>.",
|
||||
"link_to_oauth": "Link to OAuth",
|
||||
@ -1562,6 +1563,8 @@
|
||||
"multiselect_grid_edit_gps_err_read_only": "Cannot edit location of read only asset(s), skipping",
|
||||
"mute_memories": "Mute Memories",
|
||||
"my_albums": "My albums",
|
||||
"my_immich_description": "Copy current page as a My Immich link",
|
||||
"my_immich_title": "My Immich link",
|
||||
"name": "Name",
|
||||
"name_or_nickname": "Name or nickname",
|
||||
"name_required": "Name is required",
|
||||
@ -1926,6 +1929,8 @@
|
||||
"scan_settings": "Scan Settings",
|
||||
"scanning": "Scanning",
|
||||
"scanning_for_album": "Scanning for album...",
|
||||
"screencast_mode_description": "Show keyboard and mouse event indicators on the screen",
|
||||
"screencast_mode_title": "Toggle screencast mode",
|
||||
"search": "Search",
|
||||
"search_albums": "Search albums",
|
||||
"search_by_context": "Search by context",
|
||||
@ -2214,6 +2219,8 @@
|
||||
"sync_status": "Sync Status",
|
||||
"sync_status_subtitle": "View and manage the sync system",
|
||||
"sync_upload_album_setting_subtitle": "Create and upload your photos and videos to the selected albums on Immich",
|
||||
"system_theme": "System theme",
|
||||
"system_theme_command_description": "Use the system theme ({value})",
|
||||
"tag": "Tag",
|
||||
"tag_assets": "Tag assets",
|
||||
"tag_created": "Created tag: {tag}",
|
||||
|
||||
6
machine-learning/uv.lock
generated
6
machine-learning/uv.lock
generated
@ -2271,11 +2271,11 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "python-multipart"
|
||||
version = "0.0.22"
|
||||
version = "0.0.26"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/94/01/979e98d542a70714b0cb2b6728ed0b7c46792b695e3eaec3e20711271ca3/python_multipart-0.0.22.tar.gz", hash = "sha256:7340bef99a7e0032613f56dc36027b959fd3b30a787ed62d310e951f7c3a3a58", size = 37612, upload-time = "2026-01-25T10:15:56.219Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/88/71/b145a380824a960ebd60e1014256dbb7d2253f2316ff2d73dfd8928ec2c3/python_multipart-0.0.26.tar.gz", hash = "sha256:08fadc45918cd615e26846437f50c5d6d23304da32c341f289a617127b081f17", size = 43501, upload-time = "2026-04-10T14:09:59.473Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/1b/d0/397f9626e711ff749a95d96b7af99b9c566a9bb5129b8e4c10fc4d100304/python_multipart-0.0.22-py3-none-any.whl", hash = "sha256:2b2cd894c83d21bf49d702499531c7bafd057d730c201782048f7945d82de155", size = 24579, upload-time = "2026-01-25T10:15:54.811Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9a/22/f1925cdda983ab66fc8ec6ec8014b959262747e58bdca26a4e3d1da29d56/python_multipart-0.0.26-py3-none-any.whl", hash = "sha256:c0b169f8c4484c13b0dcf2ef0ec3a4adb255c4b7d18d8e420477d2b1dd03f185", size = 28847, upload-time = "2026-04-10T14:09:58.131Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@ -1,389 +0,0 @@
|
||||
package app.alextran.immich
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ContentResolver
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||
import io.flutter.plugin.common.BinaryMessenger
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.Result
|
||||
import io.flutter.plugin.common.PluginRegistry
|
||||
import java.security.MessageDigest
|
||||
import java.io.FileInputStream
|
||||
import kotlinx.coroutines.*
|
||||
import androidx.core.net.toUri
|
||||
|
||||
/**
|
||||
* Android plugin for Dart `BackgroundService` and file trash operations
|
||||
*/
|
||||
class BackgroundServicePlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware, PluginRegistry.ActivityResultListener {
|
||||
|
||||
private var methodChannel: MethodChannel? = null
|
||||
private var fileTrashChannel: MethodChannel? = null
|
||||
private var context: Context? = null
|
||||
private var pendingResult: Result? = null
|
||||
private val permissionRequestCode = 1001
|
||||
private val trashRequestCode = 1002
|
||||
private var activityBinding: ActivityPluginBinding? = null
|
||||
|
||||
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
onAttachedToEngine(binding.applicationContext, binding.binaryMessenger)
|
||||
}
|
||||
|
||||
private fun onAttachedToEngine(ctx: Context, messenger: BinaryMessenger) {
|
||||
context = ctx
|
||||
methodChannel = MethodChannel(messenger, "immich/foregroundChannel")
|
||||
methodChannel?.setMethodCallHandler(this)
|
||||
|
||||
// Add file trash channel
|
||||
fileTrashChannel = MethodChannel(messenger, "file_trash")
|
||||
fileTrashChannel?.setMethodCallHandler(this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
onDetachedFromEngine()
|
||||
}
|
||||
|
||||
private fun onDetachedFromEngine() {
|
||||
methodChannel?.setMethodCallHandler(null)
|
||||
methodChannel = null
|
||||
fileTrashChannel?.setMethodCallHandler(null)
|
||||
fileTrashChannel = null
|
||||
}
|
||||
|
||||
override fun onMethodCall(call: MethodCall, result: Result) {
|
||||
val ctx = context!!
|
||||
when (call.method) {
|
||||
// Existing BackgroundService methods
|
||||
"enable" -> {
|
||||
val args = call.arguments<ArrayList<*>>()!!
|
||||
ctx.getSharedPreferences(BackupWorker.SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.putBoolean(ContentObserverWorker.SHARED_PREF_SERVICE_ENABLED, true)
|
||||
.putLong(BackupWorker.SHARED_PREF_CALLBACK_KEY, args[0] as Long)
|
||||
.putString(BackupWorker.SHARED_PREF_NOTIFICATION_TITLE, args[1] as String)
|
||||
.apply()
|
||||
ContentObserverWorker.enable(ctx, immediate = args[2] as Boolean)
|
||||
result.success(true)
|
||||
}
|
||||
|
||||
"configure" -> {
|
||||
val args = call.arguments<ArrayList<*>>()!!
|
||||
val requireUnmeteredNetwork = args[0] as Boolean
|
||||
val requireCharging = args[1] as Boolean
|
||||
val triggerUpdateDelay = (args[2] as Number).toLong()
|
||||
val triggerMaxDelay = (args[3] as Number).toLong()
|
||||
ContentObserverWorker.configureWork(
|
||||
ctx,
|
||||
requireUnmeteredNetwork,
|
||||
requireCharging,
|
||||
triggerUpdateDelay,
|
||||
triggerMaxDelay
|
||||
)
|
||||
result.success(true)
|
||||
}
|
||||
|
||||
"disable" -> {
|
||||
ContentObserverWorker.disable(ctx)
|
||||
BackupWorker.stopWork(ctx)
|
||||
result.success(true)
|
||||
}
|
||||
|
||||
"isEnabled" -> {
|
||||
result.success(ContentObserverWorker.isEnabled(ctx))
|
||||
}
|
||||
|
||||
"isIgnoringBatteryOptimizations" -> {
|
||||
result.success(BackupWorker.isIgnoringBatteryOptimizations(ctx))
|
||||
}
|
||||
|
||||
"digestFiles" -> {
|
||||
val args = call.arguments<ArrayList<String>>()!!
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val buf = ByteArray(BUFFER_SIZE)
|
||||
val digest: MessageDigest = MessageDigest.getInstance("SHA-1")
|
||||
val hashes = arrayOfNulls<ByteArray>(args.size)
|
||||
for (i in args.indices) {
|
||||
val path = args[i]
|
||||
var len = 0
|
||||
try {
|
||||
val file = FileInputStream(path)
|
||||
file.use { assetFile ->
|
||||
while (true) {
|
||||
len = assetFile.read(buf)
|
||||
if (len != BUFFER_SIZE) break
|
||||
digest.update(buf)
|
||||
}
|
||||
}
|
||||
digest.update(buf, 0, len)
|
||||
hashes[i] = digest.digest()
|
||||
} catch (e: Exception) {
|
||||
// skip this file
|
||||
Log.w(TAG, "Failed to hash file ${args[i]}: $e")
|
||||
}
|
||||
}
|
||||
result.success(hashes.asList())
|
||||
}
|
||||
}
|
||||
|
||||
// File Trash methods moved from MainActivity
|
||||
"moveToTrash" -> {
|
||||
val mediaUrls = call.argument<List<String>>("mediaUrls")
|
||||
if (mediaUrls != null) {
|
||||
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) && hasManageMediaPermission()) {
|
||||
moveToTrash(mediaUrls, result)
|
||||
} else {
|
||||
result.error("PERMISSION_DENIED", "Media permission required", null)
|
||||
}
|
||||
} else {
|
||||
result.error("INVALID_NAME", "The mediaUrls is not specified.", null)
|
||||
}
|
||||
}
|
||||
|
||||
"restoreFromTrash" -> {
|
||||
val fileName = call.argument<String>("fileName")
|
||||
val type = call.argument<Int>("type")
|
||||
val mediaId = call.argument<String>("mediaId")
|
||||
if (fileName != null && type != null) {
|
||||
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) && hasManageMediaPermission()) {
|
||||
restoreFromTrash(fileName, type, result)
|
||||
} else {
|
||||
result.error("PERMISSION_DENIED", "Media permission required", null)
|
||||
}
|
||||
} else
|
||||
if (mediaId != null && type != null) {
|
||||
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) && hasManageMediaPermission()) {
|
||||
restoreFromTrashById(mediaId, type, result)
|
||||
} else {
|
||||
result.error("PERMISSION_DENIED", "Media permission required", null)
|
||||
}
|
||||
} else {
|
||||
result.error("INVALID_PARAMS", "Required params are not specified.", null)
|
||||
}
|
||||
}
|
||||
|
||||
"requestManageMediaPermission" -> {
|
||||
if (!hasManageMediaPermission()) {
|
||||
requestManageMediaPermission(result)
|
||||
} else {
|
||||
Log.e("Manage storage permission", "Permission already granted")
|
||||
result.success(true)
|
||||
}
|
||||
}
|
||||
|
||||
"hasManageMediaPermission" -> {
|
||||
if (hasManageMediaPermission()) {
|
||||
Log.i("Manage storage permission", "Permission already granted")
|
||||
result.success(true)
|
||||
} else {
|
||||
result.success(false)
|
||||
}
|
||||
}
|
||||
|
||||
"manageMediaPermission" -> requestManageMediaPermission(result)
|
||||
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasManageMediaPermission(): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
MediaStore.canManageMedia(context!!);
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestManageMediaPermission(result: Result) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
pendingResult = result // Store the result callback
|
||||
val activity = activityBinding?.activity ?: return
|
||||
|
||||
val intent = Intent(Settings.ACTION_REQUEST_MANAGE_MEDIA)
|
||||
intent.data = "package:${activity.packageName}".toUri()
|
||||
activity.startActivityForResult(intent, permissionRequestCode)
|
||||
} else {
|
||||
result.success(false)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun moveToTrash(mediaUrls: List<String>, result: Result) {
|
||||
val urisToTrash = mediaUrls.map { it.toUri() }
|
||||
if (urisToTrash.isEmpty()) {
|
||||
result.error("INVALID_ARGS", "No valid URIs provided", null)
|
||||
return
|
||||
}
|
||||
|
||||
toggleTrash(urisToTrash, true, result);
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun restoreFromTrash(name: String, type: Int, result: Result) {
|
||||
val uri = getTrashedFileUri(name, type)
|
||||
if (uri == null) {
|
||||
Log.e("TrashError", "Asset Uri cannot be found obtained")
|
||||
result.error("TrashError", "Asset Uri cannot be found obtained", null)
|
||||
return
|
||||
}
|
||||
Log.e("FILE_URI", uri.toString())
|
||||
uri.let { toggleTrash(listOf(it), false, result) }
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun restoreFromTrashById(mediaId: String, type: Int, result: Result) {
|
||||
val id = mediaId.toLongOrNull()
|
||||
if (id == null) {
|
||||
result.error("INVALID_ID", "The file id is not a valid number: $mediaId", null)
|
||||
return
|
||||
}
|
||||
if (!isInTrash(id)) {
|
||||
result.error("TrashNotFound", "Item with id=$id not found in trash", null)
|
||||
return
|
||||
}
|
||||
|
||||
val uri = ContentUris.withAppendedId(contentUriForType(type), id)
|
||||
|
||||
try {
|
||||
Log.i(TAG, "restoreFromTrashById: uri=$uri (type=$type,id=$id)")
|
||||
restoreUris(listOf(uri), result)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "restoreFromTrashById failed", e)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun toggleTrash(contentUris: List<Uri>, isTrashed: Boolean, result: Result) {
|
||||
val activity = activityBinding?.activity
|
||||
val contentResolver = context?.contentResolver
|
||||
if (activity == null || contentResolver == null) {
|
||||
result.error("TrashError", "Activity or ContentResolver not available", null)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
val pendingIntent = MediaStore.createTrashRequest(contentResolver, contentUris, isTrashed)
|
||||
pendingResult = result // Store for onActivityResult
|
||||
activity.startIntentSenderForResult(
|
||||
pendingIntent.intentSender,
|
||||
trashRequestCode,
|
||||
null, 0, 0, 0
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("TrashError", "Error creating or starting trash request", e)
|
||||
result.error("TrashError", "Error creating or starting trash request", null)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun getTrashedFileUri(fileName: String, type: Int): Uri? {
|
||||
val contentResolver = context?.contentResolver ?: return null
|
||||
val queryUri = MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL)
|
||||
val projection = arrayOf(MediaStore.Files.FileColumns._ID)
|
||||
|
||||
val queryArgs = Bundle().apply {
|
||||
putString(
|
||||
ContentResolver.QUERY_ARG_SQL_SELECTION,
|
||||
"${MediaStore.Files.FileColumns.DISPLAY_NAME} = ?"
|
||||
)
|
||||
putStringArray(ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS, arrayOf(fileName))
|
||||
putInt(MediaStore.QUERY_ARG_MATCH_TRASHED, MediaStore.MATCH_ONLY)
|
||||
}
|
||||
|
||||
contentResolver.query(queryUri, projection, queryArgs, null)?.use { cursor ->
|
||||
if (cursor.moveToFirst()) {
|
||||
val id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns._ID))
|
||||
return ContentUris.withAppendedId(contentUriForType(type), id)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// ActivityAware implementation
|
||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||
activityBinding = binding
|
||||
binding.addActivityResultListener(this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromActivityForConfigChanges() {
|
||||
activityBinding?.removeActivityResultListener(this)
|
||||
activityBinding = null
|
||||
}
|
||||
|
||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
||||
activityBinding = binding
|
||||
binding.addActivityResultListener(this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromActivity() {
|
||||
activityBinding?.removeActivityResultListener(this)
|
||||
activityBinding = null
|
||||
}
|
||||
|
||||
// ActivityResultListener implementation
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
||||
if (requestCode == permissionRequestCode) {
|
||||
val granted = hasManageMediaPermission()
|
||||
pendingResult?.success(granted)
|
||||
pendingResult = null
|
||||
return true
|
||||
}
|
||||
|
||||
if (requestCode == trashRequestCode) {
|
||||
val approved = resultCode == Activity.RESULT_OK
|
||||
pendingResult?.success(approved)
|
||||
pendingResult = null
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun isInTrash(id: Long): Boolean {
|
||||
val contentResolver = context?.contentResolver ?: return false
|
||||
val filesUri = MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL)
|
||||
val args = Bundle().apply {
|
||||
putString(ContentResolver.QUERY_ARG_SQL_SELECTION, "${MediaStore.Files.FileColumns._ID}=?")
|
||||
putStringArray(ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS, arrayOf(id.toString()))
|
||||
putInt(MediaStore.QUERY_ARG_MATCH_TRASHED, MediaStore.MATCH_ONLY)
|
||||
putInt(ContentResolver.QUERY_ARG_LIMIT, 1)
|
||||
}
|
||||
return contentResolver.query(filesUri, arrayOf(MediaStore.Files.FileColumns._ID), args, null)
|
||||
?.use { it.moveToFirst() } == true
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun restoreUris(uris: List<Uri>, result: Result) {
|
||||
if (uris.isEmpty()) {
|
||||
result.error("TrashError", "No URIs to restore", null)
|
||||
return
|
||||
}
|
||||
Log.i(TAG, "restoreUris: count=${uris.size}, first=${uris.first()}")
|
||||
toggleTrash(uris, false, result)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun contentUriForType(type: Int): Uri =
|
||||
when (type) {
|
||||
// same order as AssetType from dart
|
||||
1 -> MediaStore.Images.Media.EXTERNAL_CONTENT_URI
|
||||
2 -> MediaStore.Video.Media.EXTERNAL_CONTENT_URI
|
||||
3 -> MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
||||
else -> MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL)
|
||||
}
|
||||
}
|
||||
|
||||
private const val TAG = "BackgroundServicePlugin"
|
||||
private const val BUFFER_SIZE = 2 * 1024 * 1024
|
||||
@ -1,394 +0,0 @@
|
||||
package app.alextran.immich
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.PowerManager
|
||||
import android.os.SystemClock
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.concurrent.futures.ResolvableFuture
|
||||
import androidx.work.BackoffPolicy
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.ForegroundInfo
|
||||
import androidx.work.ListenableWorker
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.WorkerParameters
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.WorkInfo
|
||||
import com.google.common.util.concurrent.ListenableFuture
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.embedding.engine.dart.DartExecutor
|
||||
import io.flutter.embedding.engine.loader.FlutterLoader
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.view.FlutterCallbackInformation
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Worker executed by Android WorkManager to perform backup in background
|
||||
*
|
||||
* Starts the Dart runtime/engine and calls `_nativeEntry` function in
|
||||
* `background.service.dart` to run the actual backup logic.
|
||||
* Called by Android WorkManager when all constraints for the work are met,
|
||||
* i.e. battery is not low and optionally Wifi and charging are active.
|
||||
*/
|
||||
class BackupWorker(ctx: Context, params: WorkerParameters) : ListenableWorker(ctx, params),
|
||||
MethodChannel.MethodCallHandler {
|
||||
|
||||
private val resolvableFuture = ResolvableFuture.create<Result>()
|
||||
private var engine: FlutterEngine? = null
|
||||
private lateinit var backgroundChannel: MethodChannel
|
||||
private val notificationManager =
|
||||
ctx.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
private val isIgnoringBatteryOptimizations = isIgnoringBatteryOptimizations(applicationContext)
|
||||
private var timeBackupStarted: Long = 0L
|
||||
private var notificationBuilder: NotificationCompat.Builder? = null
|
||||
private var notificationDetailBuilder: NotificationCompat.Builder? = null
|
||||
private var fgFuture: ListenableFuture<Void>? = null
|
||||
|
||||
override fun startWork(): ListenableFuture<ListenableWorker.Result> {
|
||||
|
||||
Log.d(TAG, "startWork")
|
||||
|
||||
val ctx = applicationContext
|
||||
|
||||
if (!flutterLoader.initialized()) {
|
||||
flutterLoader.startInitialization(ctx)
|
||||
}
|
||||
|
||||
// Create a Notification channel
|
||||
createChannel()
|
||||
|
||||
Log.d(TAG, "isIgnoringBatteryOptimizations $isIgnoringBatteryOptimizations")
|
||||
if (isIgnoringBatteryOptimizations) {
|
||||
// normal background services can only up to 10 minutes
|
||||
// foreground services are allowed to run indefinitely
|
||||
// requires battery optimizations to be disabled (either manually by the user
|
||||
// or by the system learning that immich is important to the user)
|
||||
val title = ctx.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.getString(SHARED_PREF_NOTIFICATION_TITLE, NOTIFICATION_DEFAULT_TITLE)!!
|
||||
showInfo(getInfoBuilder(title, indeterminate = true).build())
|
||||
}
|
||||
|
||||
engine = FlutterEngine(ctx)
|
||||
|
||||
flutterLoader.ensureInitializationCompleteAsync(ctx, null, Handler(Looper.getMainLooper())) {
|
||||
runDart()
|
||||
|
||||
}
|
||||
|
||||
return resolvableFuture
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Dart runtime/engine and calls `_nativeEntry` function in
|
||||
* `background.service.dart` to run the actual backup logic.
|
||||
*/
|
||||
private fun runDart() {
|
||||
val callbackDispatcherHandle = applicationContext.getSharedPreferences(
|
||||
SHARED_PREF_NAME, Context.MODE_PRIVATE
|
||||
).getLong(SHARED_PREF_CALLBACK_KEY, 0L)
|
||||
val callbackInformation =
|
||||
FlutterCallbackInformation.lookupCallbackInformation(callbackDispatcherHandle)
|
||||
val appBundlePath = flutterLoader.findAppBundlePath()
|
||||
|
||||
engine?.let { engine ->
|
||||
backgroundChannel = MethodChannel(engine.dartExecutor, "immich/backgroundChannel")
|
||||
backgroundChannel.setMethodCallHandler(this@BackupWorker)
|
||||
engine.dartExecutor.executeDartCallback(
|
||||
DartExecutor.DartCallback(
|
||||
applicationContext.assets,
|
||||
appBundlePath,
|
||||
callbackInformation
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStopped() {
|
||||
Log.d(TAG, "onStopped")
|
||||
// called when the system has to stop this worker because constraints are
|
||||
// no longer met or the system needs resources for more important tasks
|
||||
Handler(Looper.getMainLooper()).postAtFrontOfQueue {
|
||||
if (::backgroundChannel.isInitialized) {
|
||||
backgroundChannel.invokeMethod("systemStop", null)
|
||||
}
|
||||
}
|
||||
waitOnSetForegroundAsync()
|
||||
// cannot await/get(block) on resolvableFuture as its already cancelled (would throw CancellationException)
|
||||
// instead, wait for 5 seconds until forcefully stopping backup work
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
stopEngine(null)
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
private fun waitOnSetForegroundAsync() {
|
||||
val fgFuture = this.fgFuture
|
||||
if (fgFuture != null && !fgFuture.isCancelled && !fgFuture.isDone) {
|
||||
try {
|
||||
fgFuture.get(500, TimeUnit.MILLISECONDS)
|
||||
} catch (e: Exception) {
|
||||
// ignored, there is nothing to be done
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopEngine(result: Result?) {
|
||||
clearBackgroundNotification()
|
||||
engine?.destroy()
|
||||
engine = null
|
||||
if (result != null) {
|
||||
Log.d(TAG, "stopEngine result=${result}")
|
||||
resolvableFuture.set(result)
|
||||
}
|
||||
waitOnSetForegroundAsync()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
override fun onMethodCall(call: MethodCall, r: MethodChannel.Result) {
|
||||
when (call.method) {
|
||||
"initialized" -> {
|
||||
timeBackupStarted = SystemClock.uptimeMillis()
|
||||
backgroundChannel.invokeMethod(
|
||||
"onAssetsChanged",
|
||||
null,
|
||||
object : MethodChannel.Result {
|
||||
override fun notImplemented() {
|
||||
stopEngine(Result.failure())
|
||||
}
|
||||
|
||||
override fun error(errorCode: String, errorMessage: String?, errorDetails: Any?) {
|
||||
stopEngine(Result.failure())
|
||||
}
|
||||
|
||||
override fun success(receivedResult: Any?) {
|
||||
val success = receivedResult as Boolean
|
||||
stopEngine(if (success) Result.success() else Result.retry())
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
"updateNotification" -> {
|
||||
val args = call.arguments<ArrayList<*>>()!!
|
||||
val title = args[0] as String?
|
||||
val content = args[1] as String?
|
||||
val progress = args[2] as Int
|
||||
val max = args[3] as Int
|
||||
val indeterminate = args[4] as Boolean
|
||||
val isDetail = args[5] as Boolean
|
||||
val onlyIfFG = args[6] as Boolean
|
||||
if (!onlyIfFG || isIgnoringBatteryOptimizations) {
|
||||
showInfo(
|
||||
getInfoBuilder(title, content, isDetail, progress, max, indeterminate).build(),
|
||||
isDetail
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
"showError" -> {
|
||||
val args = call.arguments<ArrayList<*>>()!!
|
||||
val title = args[0] as String
|
||||
val content = args[1] as String?
|
||||
val individualTag = args[2] as String?
|
||||
showError(title, content, individualTag)
|
||||
}
|
||||
|
||||
"clearErrorNotifications" -> clearErrorNotifications()
|
||||
"hasContentChanged" -> {
|
||||
val lastChange = applicationContext
|
||||
.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.getLong(SHARED_PREF_LAST_CHANGE, timeBackupStarted)
|
||||
val hasContentChanged = lastChange > timeBackupStarted;
|
||||
timeBackupStarted = SystemClock.uptimeMillis()
|
||||
r.success(hasContentChanged)
|
||||
}
|
||||
|
||||
else -> r.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showError(title: String, content: String?, individualTag: String?) {
|
||||
val notification = NotificationCompat.Builder(applicationContext, NOTIFICATION_CHANNEL_ERROR_ID)
|
||||
.setContentTitle(title)
|
||||
.setTicker(title)
|
||||
.setContentText(content)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.build()
|
||||
notificationManager.notify(individualTag, NOTIFICATION_ERROR_ID, notification)
|
||||
}
|
||||
|
||||
private fun clearErrorNotifications() {
|
||||
notificationManager.cancel(NOTIFICATION_ERROR_ID)
|
||||
}
|
||||
|
||||
private fun clearBackgroundNotification() {
|
||||
notificationManager.cancel(NOTIFICATION_ID)
|
||||
notificationManager.cancel(NOTIFICATION_DETAIL_ID)
|
||||
}
|
||||
|
||||
private fun showInfo(notification: Notification, isDetail: Boolean = false) {
|
||||
val id = if (isDetail) NOTIFICATION_DETAIL_ID else NOTIFICATION_ID
|
||||
|
||||
if (isIgnoringBatteryOptimizations && !isDetail) {
|
||||
fgFuture = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
setForegroundAsync(ForegroundInfo(id, notification, FOREGROUND_SERVICE_TYPE_SHORT_SERVICE))
|
||||
} else {
|
||||
setForegroundAsync(ForegroundInfo(id, notification))
|
||||
}
|
||||
} else {
|
||||
notificationManager.notify(id, notification)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInfoBuilder(
|
||||
title: String? = null,
|
||||
content: String? = null,
|
||||
isDetail: Boolean = false,
|
||||
progress: Int = 0,
|
||||
max: Int = 0,
|
||||
indeterminate: Boolean = false,
|
||||
): NotificationCompat.Builder {
|
||||
var builder = if (isDetail) notificationDetailBuilder else notificationBuilder
|
||||
if (builder == null) {
|
||||
builder = NotificationCompat.Builder(applicationContext, NOTIFICATION_CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setOnlyAlertOnce(true)
|
||||
.setOngoing(true)
|
||||
if (isDetail) {
|
||||
notificationDetailBuilder = builder
|
||||
} else {
|
||||
notificationBuilder = builder
|
||||
}
|
||||
}
|
||||
if (title != null) {
|
||||
builder.setTicker(title).setContentTitle(title)
|
||||
}
|
||||
if (content != null) {
|
||||
builder.setContentText(content)
|
||||
}
|
||||
return builder.setProgress(max, progress, indeterminate)
|
||||
}
|
||||
|
||||
private fun createChannel() {
|
||||
val foreground = NotificationChannel(
|
||||
NOTIFICATION_CHANNEL_ID,
|
||||
NOTIFICATION_CHANNEL_ID,
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
)
|
||||
notificationManager.createNotificationChannel(foreground)
|
||||
val error = NotificationChannel(
|
||||
NOTIFICATION_CHANNEL_ERROR_ID,
|
||||
NOTIFICATION_CHANNEL_ERROR_ID,
|
||||
NotificationManager.IMPORTANCE_HIGH
|
||||
)
|
||||
notificationManager.createNotificationChannel(error)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SHARED_PREF_NAME = "immichBackgroundService"
|
||||
const val SHARED_PREF_CALLBACK_KEY = "callbackDispatcherHandle"
|
||||
const val SHARED_PREF_NOTIFICATION_TITLE = "notificationTitle"
|
||||
const val SHARED_PREF_LAST_CHANGE = "lastChange"
|
||||
|
||||
private const val TASK_NAME_BACKUP = "immich/BackupWorker"
|
||||
private const val NOTIFICATION_CHANNEL_ID = "immich/backgroundService"
|
||||
private const val NOTIFICATION_CHANNEL_ERROR_ID = "immich/backgroundServiceError"
|
||||
private const val NOTIFICATION_DEFAULT_TITLE = "Immich"
|
||||
private const val NOTIFICATION_ID = 1
|
||||
private const val NOTIFICATION_ERROR_ID = 2
|
||||
private const val NOTIFICATION_DETAIL_ID = 3
|
||||
private const val ONE_MINUTE = 60000L
|
||||
|
||||
/**
|
||||
* Enqueues the BackupWorker to run once the constraints are met
|
||||
*/
|
||||
fun enqueueBackupWorker(
|
||||
context: Context,
|
||||
requireWifi: Boolean = false,
|
||||
requireCharging: Boolean = false,
|
||||
delayMilliseconds: Long = 0L
|
||||
) {
|
||||
val workRequest = buildWorkRequest(requireWifi, requireCharging, delayMilliseconds)
|
||||
WorkManager.getInstance(context)
|
||||
.enqueueUniqueWork(TASK_NAME_BACKUP, ExistingWorkPolicy.KEEP, workRequest)
|
||||
Log.d(TAG, "enqueueBackupWorker: BackupWorker enqueued")
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the constraints of an already enqueued BackupWorker
|
||||
*/
|
||||
fun updateBackupWorker(
|
||||
context: Context,
|
||||
requireWifi: Boolean = false,
|
||||
requireCharging: Boolean = false
|
||||
) {
|
||||
try {
|
||||
val wm = WorkManager.getInstance(context)
|
||||
val workInfoFuture = wm.getWorkInfosForUniqueWork(TASK_NAME_BACKUP)
|
||||
val workInfoList = workInfoFuture.get(1000, TimeUnit.MILLISECONDS)
|
||||
if (workInfoList != null) {
|
||||
for (workInfo in workInfoList) {
|
||||
if (workInfo.state == WorkInfo.State.ENQUEUED) {
|
||||
val workRequest = buildWorkRequest(requireWifi, requireCharging)
|
||||
wm.enqueueUniqueWork(TASK_NAME_BACKUP, ExistingWorkPolicy.REPLACE, workRequest)
|
||||
Log.d(TAG, "updateBackupWorker updated BackupWorker constraints")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "updateBackupWorker: BackupWorker not enqueued")
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "updateBackupWorker failed: $e")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the currently running worker (if any) and removes it from the work queue
|
||||
*/
|
||||
fun stopWork(context: Context) {
|
||||
WorkManager.getInstance(context).cancelUniqueWork(TASK_NAME_BACKUP)
|
||||
Log.d(TAG, "stopWork: BackupWorker cancelled")
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the app is ignoring battery optimizations
|
||||
*/
|
||||
fun isIgnoringBatteryOptimizations(ctx: Context): Boolean {
|
||||
val powerManager = ctx.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
return powerManager.isIgnoringBatteryOptimizations(ctx.packageName)
|
||||
}
|
||||
|
||||
private fun buildWorkRequest(
|
||||
requireWifi: Boolean = false,
|
||||
requireCharging: Boolean = false,
|
||||
delayMilliseconds: Long = 0L
|
||||
): OneTimeWorkRequest {
|
||||
val constraints = Constraints.Builder()
|
||||
.setRequiredNetworkType(if (requireWifi) NetworkType.UNMETERED else NetworkType.CONNECTED)
|
||||
.setRequiresBatteryNotLow(true)
|
||||
.setRequiresCharging(requireCharging)
|
||||
.build();
|
||||
|
||||
val work = OneTimeWorkRequest.Builder(BackupWorker::class.java)
|
||||
.setConstraints(constraints)
|
||||
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, ONE_MINUTE, TimeUnit.MILLISECONDS)
|
||||
.setInitialDelay(delayMilliseconds, TimeUnit.MILLISECONDS)
|
||||
.build()
|
||||
return work
|
||||
}
|
||||
|
||||
private val flutterLoader = FlutterLoader()
|
||||
}
|
||||
}
|
||||
|
||||
private const val TAG = "BackupWorker"
|
||||
@ -1,144 +0,0 @@
|
||||
package app.alextran.immich
|
||||
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.provider.MediaStore
|
||||
import android.util.Log
|
||||
import androidx.work.Constraints
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.Operation
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Worker executed by Android WorkManager observing content changes (new photos/videos)
|
||||
*
|
||||
* Immediately enqueues the BackupWorker when running.
|
||||
* As this work is not triggered periodically, but on content change, the
|
||||
* worker enqueues itself again after each run.
|
||||
*/
|
||||
class ContentObserverWorker(ctx: Context, params: WorkerParameters) : Worker(ctx, params) {
|
||||
|
||||
override fun doWork(): Result {
|
||||
if (!isEnabled(applicationContext)) {
|
||||
return Result.failure()
|
||||
}
|
||||
if (triggeredContentUris.size > 0) {
|
||||
startBackupWorker(applicationContext, delayMilliseconds = 0)
|
||||
}
|
||||
enqueueObserverWorker(applicationContext, ExistingWorkPolicy.REPLACE)
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SHARED_PREF_SERVICE_ENABLED = "serviceEnabled"
|
||||
private const val SHARED_PREF_REQUIRE_WIFI = "requireWifi"
|
||||
private const val SHARED_PREF_REQUIRE_CHARGING = "requireCharging"
|
||||
private const val SHARED_PREF_TRIGGER_UPDATE_DELAY = "triggerUpdateDelay"
|
||||
private const val SHARED_PREF_TRIGGER_MAX_DELAY = "triggerMaxDelay"
|
||||
|
||||
private const val TASK_NAME_OBSERVER = "immich/ContentObserver"
|
||||
|
||||
/**
|
||||
* Enqueues the `ContentObserverWorker`.
|
||||
*
|
||||
* @param context Android Context
|
||||
*/
|
||||
fun enable(context: Context, immediate: Boolean = false) {
|
||||
enqueueObserverWorker(context, ExistingWorkPolicy.KEEP)
|
||||
Log.d(TAG, "enabled ContentObserverWorker")
|
||||
if (immediate) {
|
||||
startBackupWorker(context, delayMilliseconds = 5000)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the `BackupWorker` to run when all constraints are met.
|
||||
*
|
||||
* @param context Android Context
|
||||
* @param requireWifi if true, task only runs if connected to wifi
|
||||
* @param requireCharging if true, task only runs if device is charging
|
||||
*/
|
||||
fun configureWork(context: Context,
|
||||
requireWifi: Boolean = false,
|
||||
requireCharging: Boolean = false,
|
||||
triggerUpdateDelay: Long = 5000,
|
||||
triggerMaxDelay: Long = 50000) {
|
||||
context.getSharedPreferences(BackupWorker.SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.putBoolean(SHARED_PREF_SERVICE_ENABLED, true)
|
||||
.putBoolean(SHARED_PREF_REQUIRE_WIFI, requireWifi)
|
||||
.putBoolean(SHARED_PREF_REQUIRE_CHARGING, requireCharging)
|
||||
.putLong(SHARED_PREF_TRIGGER_UPDATE_DELAY, triggerUpdateDelay)
|
||||
.putLong(SHARED_PREF_TRIGGER_MAX_DELAY, triggerMaxDelay)
|
||||
.apply()
|
||||
BackupWorker.updateBackupWorker(context, requireWifi, requireCharging)
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the currently running worker (if any) and removes it from the work queue
|
||||
*/
|
||||
fun disable(context: Context) {
|
||||
context.getSharedPreferences(BackupWorker.SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit().putBoolean(SHARED_PREF_SERVICE_ENABLED, false).apply()
|
||||
WorkManager.getInstance(context).cancelUniqueWork(TASK_NAME_OBSERVER)
|
||||
Log.d(TAG, "disabled ContentObserverWorker")
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the user has enabled the background backup service
|
||||
*/
|
||||
fun isEnabled(ctx: Context): Boolean {
|
||||
return ctx.getSharedPreferences(BackupWorker.SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.getBoolean(SHARED_PREF_SERVICE_ENABLED, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue and replace the worker without the content trigger but with a short delay
|
||||
*/
|
||||
fun workManagerAppClearedWorkaround(context: Context) {
|
||||
val work = OneTimeWorkRequest.Builder(ContentObserverWorker::class.java)
|
||||
.setInitialDelay(500, TimeUnit.MILLISECONDS)
|
||||
.build()
|
||||
WorkManager
|
||||
.getInstance(context)
|
||||
.enqueueUniqueWork(TASK_NAME_OBSERVER, ExistingWorkPolicy.REPLACE, work)
|
||||
.result
|
||||
.get()
|
||||
Log.d(TAG, "workManagerAppClearedWorkaround")
|
||||
}
|
||||
|
||||
private fun enqueueObserverWorker(context: Context, policy: ExistingWorkPolicy) {
|
||||
val sp = context.getSharedPreferences(BackupWorker.SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
val constraints = Constraints.Builder()
|
||||
.addContentUriTrigger(MediaStore.Images.Media.INTERNAL_CONTENT_URI, true)
|
||||
.addContentUriTrigger(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true)
|
||||
.addContentUriTrigger(MediaStore.Video.Media.INTERNAL_CONTENT_URI, true)
|
||||
.addContentUriTrigger(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, true)
|
||||
.setTriggerContentUpdateDelay(sp.getLong(SHARED_PREF_TRIGGER_UPDATE_DELAY, 5000), TimeUnit.MILLISECONDS)
|
||||
.setTriggerContentMaxDelay(sp.getLong(SHARED_PREF_TRIGGER_MAX_DELAY, 50000), TimeUnit.MILLISECONDS)
|
||||
.build()
|
||||
|
||||
val work = OneTimeWorkRequest.Builder(ContentObserverWorker::class.java)
|
||||
.setConstraints(constraints)
|
||||
.build()
|
||||
WorkManager.getInstance(context).enqueueUniqueWork(TASK_NAME_OBSERVER, policy, work)
|
||||
}
|
||||
|
||||
fun startBackupWorker(context: Context, delayMilliseconds: Long) {
|
||||
val sp = context.getSharedPreferences(BackupWorker.SHARED_PREF_NAME, Context.MODE_PRIVATE)
|
||||
if (!sp.getBoolean(SHARED_PREF_SERVICE_ENABLED, false))
|
||||
return
|
||||
val requireWifi = sp.getBoolean(SHARED_PREF_REQUIRE_WIFI, true)
|
||||
val requireCharging = sp.getBoolean(SHARED_PREF_REQUIRE_CHARGING, false)
|
||||
BackupWorker.enqueueBackupWorker(context, requireWifi, requireCharging, delayMilliseconds)
|
||||
sp.edit().putLong(BackupWorker.SHARED_PREF_LAST_CHANGE, SystemClock.uptimeMillis()).apply()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private const val TAG = "ContentObserverWorker"
|
||||
@ -18,8 +18,6 @@ class ImmichApp : Application() {
|
||||
// Thus, the BackupWorker is not started. If the system kills the process after each initialization
|
||||
// (because of low memory etc.), the backup is never performed.
|
||||
// As a workaround, we also run a backup check when initializing the application
|
||||
|
||||
ContentObserverWorker.startBackupWorker(context = this, delayMilliseconds = 0)
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
// We can only check the engine count and not the status of the lock here,
|
||||
// as the previous start might have been killed without unlocking.
|
||||
|
||||
@ -51,7 +51,6 @@ class MainActivity : FlutterFragmentActivity() {
|
||||
BackgroundWorkerFgHostApi.setUp(messenger, BackgroundWorkerApiImpl(ctx))
|
||||
ConnectivityApi.setUp(messenger, ConnectivityApiImpl(ctx))
|
||||
|
||||
flutterEngine.plugins.add(BackgroundServicePlugin())
|
||||
flutterEngine.plugins.add(backgroundEngineLockImpl)
|
||||
flutterEngine.plugins.add(nativeSyncApiImpl)
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/entities/store.entity.dart';
|
||||
import 'package:immich_mobile/main.dart' as app;
|
||||
import 'package:immich_mobile/providers/db.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
||||
import 'package:immich_mobile/utils/bootstrap.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
@ -39,20 +38,11 @@ class ImmichTestHelper {
|
||||
static Future<void> loadApp(WidgetTester tester) async {
|
||||
await EasyLocalization.ensureInitialized();
|
||||
// Clear all data from Isar (reuse existing instance if available)
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB();
|
||||
await Bootstrap.initDomain(isar, drift, logDb);
|
||||
final (drift, _) = await Bootstrap.initDomain();
|
||||
await Store.clear();
|
||||
await isar.writeTxn(() => isar.clear());
|
||||
// Load main Widget
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
dbProvider.overrideWithValue(isar),
|
||||
isarProvider.overrideWithValue(isar),
|
||||
driftProvider.overrideWith(driftOverride(drift)),
|
||||
],
|
||||
child: const app.MainWidget(),
|
||||
),
|
||||
ProviderScope(overrides: [driftProvider.overrideWith(driftOverride(drift))], child: const app.MainWidget()),
|
||||
);
|
||||
// Post run tasks
|
||||
await EasyLocalization.ensureInitialized();
|
||||
|
||||
@ -33,8 +33,6 @@ PODS:
|
||||
- Flutter
|
||||
- integration_test (0.0.1):
|
||||
- Flutter
|
||||
- isar_community_flutter_libs (1.0.0):
|
||||
- Flutter
|
||||
- local_auth_darwin (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
@ -75,16 +73,16 @@ PODS:
|
||||
- sqflite_darwin (0.0.4):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- sqlite3 (3.49.1):
|
||||
- sqlite3/common (= 3.49.1)
|
||||
- sqlite3/common (3.49.1)
|
||||
- sqlite3/dbstatvtab (3.49.1):
|
||||
- sqlite3 (3.49.2):
|
||||
- sqlite3/common (= 3.49.2)
|
||||
- sqlite3/common (3.49.2)
|
||||
- sqlite3/dbstatvtab (3.49.2):
|
||||
- sqlite3/common
|
||||
- sqlite3/fts5 (3.49.1):
|
||||
- sqlite3/fts5 (3.49.2):
|
||||
- sqlite3/common
|
||||
- sqlite3/perf-threadsafe (3.49.1):
|
||||
- sqlite3/perf-threadsafe (3.49.2):
|
||||
- sqlite3/common
|
||||
- sqlite3/rtree (3.49.1):
|
||||
- sqlite3/rtree (3.49.2):
|
||||
- sqlite3/common
|
||||
- sqlite3_flutter_libs (0.0.1):
|
||||
- Flutter
|
||||
@ -116,7 +114,6 @@ DEPENDENCIES:
|
||||
- home_widget (from `.symlinks/plugins/home_widget/ios`)
|
||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||
- integration_test (from `.symlinks/plugins/integration_test/ios`)
|
||||
- isar_community_flutter_libs (from `.symlinks/plugins/isar_community_flutter_libs/ios`)
|
||||
- local_auth_darwin (from `.symlinks/plugins/local_auth_darwin/darwin`)
|
||||
- maplibre_gl (from `.symlinks/plugins/maplibre_gl/ios`)
|
||||
- native_video_player (from `.symlinks/plugins/native_video_player/ios`)
|
||||
@ -174,8 +171,6 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||
integration_test:
|
||||
:path: ".symlinks/plugins/integration_test/ios"
|
||||
isar_community_flutter_libs:
|
||||
:path: ".symlinks/plugins/isar_community_flutter_libs/ios"
|
||||
local_auth_darwin:
|
||||
:path: ".symlinks/plugins/local_auth_darwin/darwin"
|
||||
maplibre_gl:
|
||||
@ -228,7 +223,6 @@ SPEC CHECKSUMS:
|
||||
home_widget: f169fc41fd807b4d46ab6615dc44d62adbf9f64f
|
||||
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
|
||||
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
|
||||
isar_community_flutter_libs: bede843185a61a05ff364a05c9b23209523f7e0d
|
||||
local_auth_darwin: 553ce4f9b16d3fdfeafce9cf042e7c9f77c1c391
|
||||
MapLibre: 69e572367f4ef6287e18246cfafc39c80cdcabcd
|
||||
maplibre_gl: 3c924e44725147b03dda33430ad216005b40555f
|
||||
@ -245,7 +239,7 @@ SPEC CHECKSUMS:
|
||||
share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58a
|
||||
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
|
||||
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
|
||||
sqlite3: fc1400008a9b3525f5914ed715a5d1af0b8f4983
|
||||
sqlite3: 3c950dc86011117c307eb0b28c4a7bb449dce9f1
|
||||
sqlite3_flutter_libs: f8fc13346870e73fe35ebf6dbb997fbcd156b241
|
||||
url_launcher_ios: 694010445543906933d732453a59da0a173ae33d
|
||||
wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556
|
||||
|
||||
@ -10,8 +10,6 @@
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3B6A31FED0FC846D6BD69BBC /* Pods_ShareExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 357FC57E54FD0F51795CF28A /* Pods_ShareExtension.framework */; };
|
||||
65F32F31299BD2F800CE9261 /* BackgroundServicePlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F32F30299BD2F800CE9261 /* BackgroundServicePlugin.swift */; };
|
||||
65F32F33299D349D00CE9261 /* BackgroundSyncWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65F32F32299D349D00CE9261 /* BackgroundSyncWorker.swift */; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
@ -90,8 +88,6 @@
|
||||
357FC57E54FD0F51795CF28A /* Pods_ShareExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ShareExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
571EAA93D77181C7C98C2EA6 /* Pods-ShareExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ShareExtension.release.xcconfig"; path = "Target Support Files/Pods-ShareExtension/Pods-ShareExtension.release.xcconfig"; sourceTree = "<group>"; };
|
||||
65F32F30299BD2F800CE9261 /* BackgroundServicePlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundServicePlugin.swift; sourceTree = "<group>"; };
|
||||
65F32F32299D349D00CE9261 /* BackgroundSyncWorker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundSyncWorker.swift; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
@ -151,11 +147,15 @@
|
||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||
B231F52D2E93A44A00BC45D1 /* Core */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
);
|
||||
path = Core;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B2CF7F8C2DDE4EBB00744BF6 /* Sync */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
);
|
||||
path = Sync;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@ -177,6 +177,8 @@
|
||||
};
|
||||
FEE084F22EC172080045228E /* Schemas */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
);
|
||||
path = Schemas;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@ -238,15 +240,6 @@
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
65DD438629917FAD0047FFA8 /* BackgroundSync */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
65F32F32299D349D00CE9261 /* BackgroundSyncWorker.swift */,
|
||||
65F32F30299BD2F800CE9261 /* BackgroundServicePlugin.swift */,
|
||||
);
|
||||
path = BackgroundSync;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -291,7 +284,6 @@
|
||||
B21E34A62E5AF9760031FDB9 /* Background */,
|
||||
B2CF7F8C2DDE4EBB00744BF6 /* Sync */,
|
||||
FA9973382CF6DF4B000EF859 /* Runner.entitlements */,
|
||||
65DD438629917FAD0047FFA8 /* BackgroundSync */,
|
||||
FAC7416727DB9F5500C668D8 /* RunnerProfile.entitlements */,
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||
@ -571,14 +563,10 @@
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||
@ -607,14 +595,10 @@
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
@ -627,7 +611,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
65F32F31299BD2F800CE9261 /* BackgroundServicePlugin.swift in Sources */,
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||
A01DD69B2F7F43B40049AB63 /* ImageRequest.swift in Sources */,
|
||||
B21E34AC2E5B09190031FDB9 /* BackgroundWorker.swift in Sources */,
|
||||
@ -642,7 +625,6 @@
|
||||
B21E34AA2E5AFD2B0031FDB9 /* BackgroundWorkerApiImpl.swift in Sources */,
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||
B2BE315F2E5E5229006EEF88 /* BackgroundWorker.g.swift in Sources */,
|
||||
65F32F33299D349D00CE9261 /* BackgroundSyncWorker.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -1261,7 +1243,7 @@
|
||||
repositoryURL = "https://github.com/pointfreeco/sqlite-data";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 1.3.0;
|
||||
minimumVersion = 1.6.1;
|
||||
};
|
||||
};
|
||||
FEE084F92EC1725A0045228E /* XCRemoteSwiftPackageReference "swift-http-structured-headers" */ = {
|
||||
@ -1269,7 +1251,7 @@
|
||||
repositoryURL = "https://github.com/apple/swift-http-structured-headers.git";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 1.5.0;
|
||||
minimumVersion = 1.6.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
@ -24,8 +24,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/sqlite-data",
|
||||
"state" : {
|
||||
"revision" : "05704b563ecb7f0bd7e49b6f360a6383a3e53e7d",
|
||||
"version" : "1.5.1"
|
||||
"revision" : "da3a94ed49c7a30d82853de551c07a93196e8cab",
|
||||
"version" : "1.6.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -78,8 +78,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-http-structured-headers.git",
|
||||
"state" : {
|
||||
"revision" : "a9f3c352f4d46afd155e00b3c6e85decae6bcbeb",
|
||||
"version" : "1.5.0"
|
||||
"revision" : "76d7627bd88b47bf5a0f8497dd244885960dde0b",
|
||||
"version" : "1.6.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -123,8 +123,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/pointfreeco/swift-structured-queries",
|
||||
"state" : {
|
||||
"revision" : "d8163b3a98f3c8434c4361e85126db449d84bc66",
|
||||
"version" : "0.30.0"
|
||||
"revision" : "8da8818fccd9959bd683934ddc62cf45bb65b3c8",
|
||||
"version" : "0.31.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -24,33 +24,8 @@ import UIKit
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
|
||||
AppDelegate.registerPlugins(with: controller.engine, controller: controller)
|
||||
BackgroundServicePlugin.register(with: self.registrar(forPlugin: "BackgroundServicePlugin")!)
|
||||
|
||||
BackgroundServicePlugin.registerBackgroundProcessing()
|
||||
BackgroundWorkerApiImpl.registerBackgroundWorkers()
|
||||
|
||||
BackgroundServicePlugin.setPluginRegistrantCallback { registry in
|
||||
if !registry.hasPlugin("org.cocoapods.path-provider-foundation") {
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "org.cocoapods.path-provider-foundation")!)
|
||||
}
|
||||
|
||||
if !registry.hasPlugin("org.cocoapods.photo-manager") {
|
||||
PhotoManagerPlugin.register(with: registry.registrar(forPlugin: "org.cocoapods.photo-manager")!)
|
||||
}
|
||||
|
||||
if !registry.hasPlugin("org.cocoapods.shared-preferences-foundation") {
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "org.cocoapods.shared-preferences-foundation")!)
|
||||
}
|
||||
|
||||
if !registry.hasPlugin("org.cocoapods.permission-handler-apple") {
|
||||
PermissionHandlerPlugin.register(with: registry.registrar(forPlugin: "org.cocoapods.permission-handler-apple")!)
|
||||
}
|
||||
|
||||
if !registry.hasPlugin("org.cocoapods.network-info-plus") {
|
||||
FPPNetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "org.cocoapods.network-info-plus")!)
|
||||
}
|
||||
}
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
|
||||
@ -1,408 +0,0 @@
|
||||
//
|
||||
// BackgroundServicePlugin.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by Marty Fuhry on 2/14/23.
|
||||
//
|
||||
|
||||
import Flutter
|
||||
import BackgroundTasks
|
||||
import path_provider_foundation
|
||||
import CryptoKit
|
||||
import Network
|
||||
|
||||
class BackgroundServicePlugin: NSObject, FlutterPlugin {
|
||||
|
||||
public static var flutterPluginRegistrantCallback: FlutterPluginRegistrantCallback?
|
||||
|
||||
public static func setPluginRegistrantCallback(_ callback: FlutterPluginRegistrantCallback) {
|
||||
flutterPluginRegistrantCallback = callback
|
||||
}
|
||||
|
||||
// Pause the application in XCode, then enter
|
||||
// e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"app.alextran.immich.backgroundFetch"]
|
||||
// or
|
||||
// e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"app.alextran.immich.backgroundProcessing"]
|
||||
// Then resume the application see the background code run
|
||||
// Tested on a physical device, not a simulator
|
||||
// This will submit either the Fetch or Processing command to the BGTaskScheduler for immediate processing.
|
||||
// In my tests, I can only get app.alextran.immich.backgroundProcessing simulated by running the above command
|
||||
|
||||
// This is the task ID in Info.plist to register as our background task ID
|
||||
public static let backgroundFetchTaskID = "app.alextran.immich.backgroundFetch"
|
||||
public static let backgroundProcessingTaskID = "app.alextran.immich.backgroundProcessing"
|
||||
|
||||
// Establish communication with the main isolate and set up the channel call
|
||||
// to this BackgroundServicePlugion()
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(
|
||||
name: "immich/foregroundChannel",
|
||||
binaryMessenger: registrar.messenger()
|
||||
)
|
||||
|
||||
let instance = BackgroundServicePlugin()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
registrar.addApplicationDelegate(instance)
|
||||
}
|
||||
|
||||
// Registers the Flutter engine with the plugins, used by the other Background Flutter engine
|
||||
public static func register(engine: FlutterEngine) {
|
||||
GeneratedPluginRegistrant.register(with: engine)
|
||||
}
|
||||
|
||||
// Registers the task IDs from the system so that we can process them here in this class
|
||||
public static func registerBackgroundProcessing() {
|
||||
|
||||
let processingRegisterd = BGTaskScheduler.shared.register(
|
||||
forTaskWithIdentifier: backgroundProcessingTaskID,
|
||||
using: nil) { task in
|
||||
if task is BGProcessingTask {
|
||||
handleBackgroundProcessing(task: task as! BGProcessingTask)
|
||||
}
|
||||
}
|
||||
|
||||
let fetchRegisterd = BGTaskScheduler.shared.register(
|
||||
forTaskWithIdentifier: backgroundFetchTaskID,
|
||||
using: nil) { task in
|
||||
if task is BGAppRefreshTask {
|
||||
handleBackgroundFetch(task: task as! BGAppRefreshTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handles the channel methods from Flutter
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "enable":
|
||||
handleBackgroundEnable(call: call, result: result)
|
||||
break
|
||||
case "configure":
|
||||
handleConfigure(call: call, result: result)
|
||||
break
|
||||
case "disable":
|
||||
handleDisable(call: call, result: result)
|
||||
break
|
||||
case "isEnabled":
|
||||
handleIsEnabled(call: call, result: result)
|
||||
break
|
||||
case "isIgnoringBatteryOptimizations":
|
||||
result(FlutterMethodNotImplemented)
|
||||
break
|
||||
case "lastBackgroundFetchTime":
|
||||
let defaults = UserDefaults.standard
|
||||
let lastRunTime = defaults.value(forKey: "last_background_fetch_run_time")
|
||||
result(lastRunTime)
|
||||
break
|
||||
case "lastBackgroundProcessingTime":
|
||||
let defaults = UserDefaults.standard
|
||||
let lastRunTime = defaults.value(forKey: "last_background_processing_run_time")
|
||||
result(lastRunTime)
|
||||
break
|
||||
case "numberOfBackgroundProcesses":
|
||||
handleNumberOfProcesses(call: call, result: result)
|
||||
break
|
||||
case "backgroundAppRefreshEnabled":
|
||||
handleBackgroundRefreshStatus(call: call, result: result)
|
||||
break
|
||||
case "digestFiles":
|
||||
handleDigestFiles(call: call, result: result)
|
||||
break
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Calculates the SHA-1 hash of each file from the list of paths provided
|
||||
func handleDigestFiles(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
|
||||
let bufsize = 2 * 1024 * 1024
|
||||
// Private error to throw if file cannot be read
|
||||
enum DigestError: String, LocalizedError {
|
||||
case NoFileHandle = "Cannot Open File Handle"
|
||||
|
||||
public var errorDescription: String? { self.rawValue }
|
||||
}
|
||||
|
||||
// Parse the arguments or else fail
|
||||
guard let args = call.arguments as? Array<String> else {
|
||||
print("Cannot parse args as array: \(String(describing: call.arguments))")
|
||||
result(FlutterError(code: "Malformed",
|
||||
message: "Received args is not an Array<String>",
|
||||
details: nil))
|
||||
return
|
||||
}
|
||||
|
||||
// Compute hash in background thread
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
var hashes: [FlutterStandardTypedData?] = Array(repeating: nil, count: args.count)
|
||||
for i in (0 ..< args.count) {
|
||||
do {
|
||||
guard let file = FileHandle(forReadingAtPath: args[i]) else { throw DigestError.NoFileHandle }
|
||||
var hasher = Insecure.SHA1.init();
|
||||
while autoreleasepool(invoking: {
|
||||
let chunk = file.readData(ofLength: bufsize)
|
||||
guard !chunk.isEmpty else { return false } // EOF
|
||||
hasher.update(data: chunk)
|
||||
return true // continue
|
||||
}) { }
|
||||
let digest = hasher.finalize()
|
||||
hashes[i] = FlutterStandardTypedData(bytes: Data(Array(digest.makeIterator())))
|
||||
} catch {
|
||||
print("Cannot calculate the digest of the file \(args[i]) due to \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
// Return result in main thread
|
||||
DispatchQueue.main.async {
|
||||
result(Array(hashes))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called by the flutter code when enabled so that we can turn on the background services
|
||||
// and save the callback information to communicate on this method channel
|
||||
public func handleBackgroundEnable(call: FlutterMethodCall, result: FlutterResult) {
|
||||
|
||||
// Needs to parse the arguments from the method call
|
||||
guard let args = call.arguments as? Array<Any> else {
|
||||
print("Cannot parse args as array: \(call.arguments)")
|
||||
result(FlutterMethodNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
// Requires 3 arguments in the array
|
||||
guard args.count == 3 else {
|
||||
print("Requires 3 arguments and received \(args.count)")
|
||||
result(FlutterMethodNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
// Parses the arguments
|
||||
let callbackHandle = args[0] as? Int64
|
||||
let notificationTitle = args[1] as? String
|
||||
let instant = args[2] as? Bool
|
||||
|
||||
// Write enabled to settings
|
||||
let defaults = UserDefaults.standard
|
||||
|
||||
// We are now enabled, so store this
|
||||
defaults.set(true, forKey: "background_service_enabled")
|
||||
|
||||
// The callback handle is an int64 address to communicate with the main isolate's
|
||||
// entry function
|
||||
defaults.set(callbackHandle, forKey: "callback_handle")
|
||||
|
||||
// This is not used yet and will need to be implemented
|
||||
defaults.set(notificationTitle, forKey: "notification_title")
|
||||
|
||||
// Schedule the background services
|
||||
BackgroundServicePlugin.scheduleBackgroundSync()
|
||||
BackgroundServicePlugin.scheduleBackgroundFetch()
|
||||
|
||||
result(true)
|
||||
}
|
||||
|
||||
// Called by the flutter code at launch to see if the background service is enabled or not
|
||||
func handleIsEnabled(call: FlutterMethodCall, result: FlutterResult) {
|
||||
let defaults = UserDefaults.standard
|
||||
let enabled = defaults.value(forKey: "background_service_enabled") as? Bool
|
||||
|
||||
// False by default
|
||||
result(enabled ?? false)
|
||||
}
|
||||
|
||||
// Called by the Flutter code whenever a change in configuration is set
|
||||
func handleConfigure(call: FlutterMethodCall, result: FlutterResult) {
|
||||
|
||||
// Needs to be able to parse the arguments or else fail
|
||||
guard let args = call.arguments as? Array<Any> else {
|
||||
print("Cannot parse args as array: \(call.arguments)")
|
||||
result(FlutterError())
|
||||
return
|
||||
}
|
||||
|
||||
// Needs to have 4 arguments in the call or else fail
|
||||
guard args.count == 4 else {
|
||||
print("Not enough arguments, 4 required: \(args.count) given")
|
||||
result(FlutterError())
|
||||
return
|
||||
}
|
||||
|
||||
// Parse the arguments from the method call
|
||||
let requireUnmeteredNetwork = args[0] as? Bool
|
||||
let requireCharging = args[1] as? Bool
|
||||
let triggerUpdateDelay = args[2] as? Int
|
||||
let triggerMaxDelay = args[3] as? Int
|
||||
|
||||
// Store the values from the call in the defaults
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.set(requireUnmeteredNetwork, forKey: "require_unmetered_network")
|
||||
defaults.set(requireCharging, forKey: "require_charging")
|
||||
defaults.set(triggerUpdateDelay, forKey: "trigger_update_delay")
|
||||
defaults.set(triggerMaxDelay, forKey: "trigger_max_delay")
|
||||
|
||||
// Cancel the background services and reschedule them
|
||||
BGTaskScheduler.shared.cancelAllTaskRequests()
|
||||
BackgroundServicePlugin.scheduleBackgroundSync()
|
||||
BackgroundServicePlugin.scheduleBackgroundFetch()
|
||||
result(true)
|
||||
}
|
||||
|
||||
// Returns the number of currently scheduled background processes to Flutter, strictly
|
||||
// for debugging
|
||||
func handleNumberOfProcesses(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
BGTaskScheduler.shared.getPendingTaskRequests { requests in
|
||||
result(requests.count)
|
||||
}
|
||||
}
|
||||
|
||||
// Disables the service, cancels all the task requests
|
||||
func handleDisable(call: FlutterMethodCall, result: FlutterResult) {
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.set(false, forKey: "background_service_enabled")
|
||||
|
||||
BGTaskScheduler.shared.cancelAllTaskRequests()
|
||||
result(true)
|
||||
}
|
||||
|
||||
// Checks the status of the Background App Refresh from the system
|
||||
// Returns true if the service is enabled for Immich, and false otherwise
|
||||
func handleBackgroundRefreshStatus(call: FlutterMethodCall, result: FlutterResult) {
|
||||
switch UIApplication.shared.backgroundRefreshStatus {
|
||||
case .available:
|
||||
result(true)
|
||||
break
|
||||
case .denied:
|
||||
result(false)
|
||||
break
|
||||
case .restricted:
|
||||
result(false)
|
||||
break
|
||||
default:
|
||||
result(false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Schedules a short-running background sync to sync only a few photos
|
||||
static func scheduleBackgroundFetch() {
|
||||
// We will schedule this task to run no matter the charging or wifi requirents from the end user
|
||||
// 1. They can set Background App Refresh to Off / Wi-Fi / Wi-Fi & Cellular Data from Settings
|
||||
// 2. We will check the battery connectivity when we begin running the background activity
|
||||
let backgroundFetch = BGAppRefreshTaskRequest(identifier: BackgroundServicePlugin.backgroundFetchTaskID)
|
||||
|
||||
// Use 5 minutes from now as earliest begin date
|
||||
backgroundFetch.earliestBeginDate = Date(timeIntervalSinceNow: 5 * 60)
|
||||
|
||||
do {
|
||||
try BGTaskScheduler.shared.submit(backgroundFetch)
|
||||
} catch {
|
||||
print("Could not schedule the background task \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
// Schedules a long-running background sync for syncing all of the photos
|
||||
static func scheduleBackgroundSync() {
|
||||
let backgroundProcessing = BGProcessingTaskRequest(identifier: BackgroundServicePlugin.backgroundProcessingTaskID)
|
||||
|
||||
// We need the values for requiring charging
|
||||
let defaults = UserDefaults.standard
|
||||
let requireCharging = defaults.value(forKey: "require_charging") as? Bool
|
||||
|
||||
// Always require network connectivity, and set the require charging from the above
|
||||
backgroundProcessing.requiresNetworkConnectivity = true
|
||||
backgroundProcessing.requiresExternalPower = requireCharging ?? true
|
||||
|
||||
// Use 15 minutes from now as earliest begin date
|
||||
backgroundProcessing.earliestBeginDate = Date(timeIntervalSinceNow: 15 * 60)
|
||||
|
||||
do {
|
||||
// Submit the task to the scheduler
|
||||
try BGTaskScheduler.shared.submit(backgroundProcessing)
|
||||
} catch {
|
||||
print("Could not schedule the background task \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
||||
// This function runs when the system kicks off the BGAppRefreshTask from the Background Task Scheduler
|
||||
static func handleBackgroundFetch(task: BGAppRefreshTask) {
|
||||
// Schedule the next sync task so we can run this again later
|
||||
scheduleBackgroundFetch()
|
||||
|
||||
// Log the time of last background processing to now
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.set(Date().timeIntervalSince1970, forKey: "last_background_fetch_run_time")
|
||||
|
||||
// If we have required charging, we should check the charging status
|
||||
let requireCharging = defaults.value(forKey: "require_charging") as? Bool ?? false
|
||||
if (requireCharging) {
|
||||
UIDevice.current.isBatteryMonitoringEnabled = true
|
||||
if (UIDevice.current.batteryState == .unplugged) {
|
||||
// The device is unplugged and we have required charging
|
||||
// Therefore, we will simply complete the task without
|
||||
// running it.
|
||||
task.setTaskCompleted(success: true)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// If we have required Wi-Fi, we can check the isExpensive property
|
||||
let requireWifi = defaults.value(forKey: "require_wifi") as? Bool ?? false
|
||||
if (requireWifi) {
|
||||
let wifiMonitor = NWPathMonitor(requiredInterfaceType: .wifi)
|
||||
let isExpensive = wifiMonitor.currentPath.isExpensive
|
||||
if (isExpensive) {
|
||||
// The network is expensive and we have required Wi-Fi
|
||||
// Therefore, we will simply complete the task without
|
||||
// running it
|
||||
task.setTaskCompleted(success: true)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule the next sync task so we can run this again later
|
||||
scheduleBackgroundFetch()
|
||||
|
||||
// The background sync task should only run for 20 seconds at most
|
||||
BackgroundServicePlugin.runBackgroundSync(task, maxSeconds: 20)
|
||||
}
|
||||
|
||||
// This function runs when the system kicks off the BGProcessingTask from the Background Task Scheduler
|
||||
static func handleBackgroundProcessing(task: BGProcessingTask) {
|
||||
// Schedule the next sync task so we run this again later
|
||||
scheduleBackgroundSync()
|
||||
|
||||
// Log the time of last background processing to now
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.set(Date().timeIntervalSince1970, forKey: "last_background_processing_run_time")
|
||||
|
||||
// We won't specify a max time for the background sync service, so this can run for longer
|
||||
BackgroundServicePlugin.runBackgroundSync(task, maxSeconds: nil)
|
||||
}
|
||||
|
||||
// This is a synchronous function which uses a semaphore to run the background sync worker's run
|
||||
// function, which will create a background Isolate and communicate with the Flutter code to back
|
||||
// up the assets. When it completes, we signal the semaphore and complete the execution allowing the
|
||||
// control to pass back to the caller synchronously
|
||||
static func runBackgroundSync(_ task: BGTask, maxSeconds: Int?) {
|
||||
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
DispatchQueue.main.async {
|
||||
let backgroundWorker = BackgroundSyncWorker { _ in
|
||||
semaphore.signal()
|
||||
}
|
||||
task.expirationHandler = {
|
||||
backgroundWorker.cancel()
|
||||
task.setTaskCompleted(success: true)
|
||||
}
|
||||
|
||||
backgroundWorker.run(maxSeconds: maxSeconds)
|
||||
task.setTaskCompleted(success: true)
|
||||
}
|
||||
semaphore.wait()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,271 +0,0 @@
|
||||
//
|
||||
// BackgroundSyncProcessing.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by Marty Fuhry on 2/6/23.
|
||||
//
|
||||
// Credit to https://github.com/fluttercommunity/flutter_workmanager/blob/main/ios/Classes/BackgroundWorker.swift
|
||||
|
||||
import Foundation
|
||||
import Flutter
|
||||
import BackgroundTasks
|
||||
|
||||
// The background worker which creates a new Flutter VM, communicates with it
|
||||
// to run the backup job, and then finishes execution and calls back to its callback
|
||||
// handler
|
||||
class BackgroundSyncWorker {
|
||||
|
||||
// The Flutter engine we create for background execution.
|
||||
// This is not the main Flutter engine which shows the UI,
|
||||
// this is a brand new isolate created and managed in this code
|
||||
// here. It does not share memory with the main
|
||||
// Flutter engine which shows the UI.
|
||||
// It needs to be started up, registered, and torn down here
|
||||
let engine: FlutterEngine? = FlutterEngine(
|
||||
name: "BackgroundImmich"
|
||||
)
|
||||
|
||||
let notificationId = "com.alextran.immich/backgroundNotifications"
|
||||
// The background message passing channel
|
||||
var channel: FlutterMethodChannel?
|
||||
|
||||
var completionHandler: (UIBackgroundFetchResult) -> Void
|
||||
let taskSessionStart = Date()
|
||||
|
||||
// We need the completion handler to tell the system when we are done running
|
||||
init(_ completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||
|
||||
// This is the background message passing channel to be used with the background engine
|
||||
// created here in this platform code
|
||||
self.channel = FlutterMethodChannel(
|
||||
name: "immich/backgroundChannel",
|
||||
binaryMessenger: engine!.binaryMessenger
|
||||
)
|
||||
self.completionHandler = completionHandler
|
||||
}
|
||||
|
||||
// Handles all of the messages from the Flutter VM called into this platform code
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "initialized":
|
||||
// Initialize tells us that we can now call into the Flutter VM to tell it to begin the update
|
||||
self.channel?.invokeMethod(
|
||||
"backgroundProcessing",
|
||||
arguments: nil,
|
||||
result: { flutterResult in
|
||||
|
||||
// This is the result we send back to the BGTaskScheduler to let it know whether we'll need more time later or
|
||||
// if this execution failed
|
||||
let result: UIBackgroundFetchResult = (flutterResult as? Bool ?? false) ? .newData : .failed
|
||||
|
||||
// Show the task duration
|
||||
let taskSessionCompleter = Date()
|
||||
let taskDuration = taskSessionCompleter.timeIntervalSince(self.taskSessionStart)
|
||||
print("[\(String(describing: self))] \(#function) -> performBackgroundRequest.\(result) (finished in \(taskDuration) seconds)")
|
||||
|
||||
// Complete the execution
|
||||
self.complete(result)
|
||||
})
|
||||
break
|
||||
case "updateNotification":
|
||||
let handled = self.handleNotification(call)
|
||||
result(handled)
|
||||
break
|
||||
case "showError":
|
||||
let handled = self.handleError(call)
|
||||
result(handled)
|
||||
break
|
||||
case "clearErrorNotifications":
|
||||
self.handleClearErrorNotifications()
|
||||
result(true)
|
||||
break
|
||||
case "hasContentChanged":
|
||||
// This is only called for Android, but we provide an implementation here
|
||||
// telling Flutter that we don't have any information about whether the gallery
|
||||
// contents have changed or not, so we can just say "no, they've not changed"
|
||||
result(false)
|
||||
break
|
||||
default:
|
||||
result(FlutterError())
|
||||
self.complete(UIBackgroundFetchResult.failed)
|
||||
}
|
||||
}
|
||||
|
||||
// Runs the background sync by starting up a new isolate and handling the calls
|
||||
// until it completes
|
||||
public func run(maxSeconds: Int?) {
|
||||
// We need the callback handle to start up the Flutter VM from the entry point
|
||||
let defaults = UserDefaults.standard
|
||||
guard let callbackHandle = defaults.value(forKey: "callback_handle") as? Int64 else {
|
||||
// Can't find the callback handle, this is fatal
|
||||
complete(UIBackgroundFetchResult.failed)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
// Use the provided callbackHandle to get the callback function
|
||||
guard let callback = FlutterCallbackCache.lookupCallbackInformation(callbackHandle) else {
|
||||
// We need this callback or else this is fatal
|
||||
complete(UIBackgroundFetchResult.failed)
|
||||
return
|
||||
}
|
||||
|
||||
// Sanity check for the engine existing
|
||||
if engine == nil {
|
||||
complete(UIBackgroundFetchResult.failed)
|
||||
return
|
||||
}
|
||||
|
||||
// Run the engine
|
||||
let isRunning = engine!.run(
|
||||
withEntrypoint: callback.callbackName,
|
||||
libraryURI: callback.callbackLibraryPath
|
||||
)
|
||||
|
||||
// If this engine isn't running, this is fatal
|
||||
if !isRunning {
|
||||
complete(UIBackgroundFetchResult.failed)
|
||||
return
|
||||
}
|
||||
|
||||
// If we have a timer, we need to start the timer to cancel ourselves
|
||||
// so that we don't run longer than the provided maxSeconds
|
||||
// After maxSeconds has elapsed, we will invoke "systemStop"
|
||||
if maxSeconds != nil {
|
||||
// Schedule a non-repeating timer to run after maxSeconds
|
||||
let timer = Timer.scheduledTimer(withTimeInterval: TimeInterval(maxSeconds!),
|
||||
repeats: false) { timer in
|
||||
// The callback invalidates the timer and stops execution
|
||||
timer.invalidate()
|
||||
|
||||
// If the channel is already deallocated, we don't need to do anything
|
||||
if self.channel == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Tell the Flutter VM to stop backing up now
|
||||
self.channel?.invokeMethod(
|
||||
"systemStop",
|
||||
arguments: nil,
|
||||
result: nil)
|
||||
|
||||
// Complete the execution
|
||||
self.complete(UIBackgroundFetchResult.newData)
|
||||
}
|
||||
}
|
||||
|
||||
// Set the handle function to the channel message handler
|
||||
self.channel?.setMethodCallHandler(handle)
|
||||
|
||||
// Register this to get access to the plugins on the platform channel
|
||||
BackgroundServicePlugin.flutterPluginRegistrantCallback?(engine!)
|
||||
}
|
||||
|
||||
// Cancels execution of this task, used by the system's task expiration handler
|
||||
// which is called shortly before execution is about to expire
|
||||
public func cancel() {
|
||||
// If the channel is already deallocated, we don't need to do anything
|
||||
if self.channel == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Tell the Flutter VM to stop backing up now
|
||||
self.channel?.invokeMethod(
|
||||
"systemStop",
|
||||
arguments: nil,
|
||||
result: nil)
|
||||
|
||||
// Complete the execution
|
||||
self.complete(UIBackgroundFetchResult.newData)
|
||||
}
|
||||
|
||||
// Completes the execution, destroys the engine, and sends a completion to our callback completionHandler
|
||||
private func complete(_ fetchResult: UIBackgroundFetchResult) {
|
||||
engine?.destroyContext()
|
||||
channel = nil
|
||||
completionHandler(fetchResult)
|
||||
}
|
||||
|
||||
private func handleNotification(_ call: FlutterMethodCall) -> Bool {
|
||||
|
||||
// Parse the arguments as an array list
|
||||
guard let args = call.arguments as? Array<Any> else {
|
||||
print("Failed to parse \(call.arguments) as array")
|
||||
return false;
|
||||
}
|
||||
|
||||
// Requires 7 arguments passed or else fail
|
||||
guard args.count == 7 else {
|
||||
print("Needs 7 arguments, but was only passed \(args.count)")
|
||||
return false
|
||||
}
|
||||
|
||||
// Parse the arguments to send the notification update
|
||||
let title = args[0] as? String
|
||||
let content = args[1] as? String
|
||||
let progress = args[2] as? Int
|
||||
let maximum = args[3] as? Int
|
||||
let indeterminate = args[4] as? Bool
|
||||
let isDetail = args[5] as? Bool
|
||||
let onlyIfForeground = args[6] as? Bool
|
||||
|
||||
// Build the notification
|
||||
let notificationContent = UNMutableNotificationContent()
|
||||
notificationContent.body = content ?? "Uploading..."
|
||||
notificationContent.title = title ?? "Immich"
|
||||
|
||||
// Add it to the Notification center
|
||||
let notification = UNNotificationRequest(
|
||||
identifier: notificationId,
|
||||
content: notificationContent,
|
||||
trigger: nil
|
||||
)
|
||||
let center = UNUserNotificationCenter.current()
|
||||
center.add(notification) { (error: Error?) in
|
||||
if let theError = error {
|
||||
print("Error showing notifications: \(theError)")
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private func handleError(_ call: FlutterMethodCall) -> Bool {
|
||||
// Parse the arguments as an array list
|
||||
guard let args = call.arguments as? Array<Any> else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Requires 7 arguments passed or else fail
|
||||
guard args.count == 3 else {
|
||||
return false
|
||||
}
|
||||
|
||||
let title = args[0] as? String
|
||||
let content = args[1] as? String
|
||||
let individualTag = args[2] as? String
|
||||
|
||||
// Build the notification
|
||||
let notificationContent = UNMutableNotificationContent()
|
||||
notificationContent.body = content ?? "Error running the backup job."
|
||||
notificationContent.title = title ?? "Immich"
|
||||
|
||||
// Add it to the Notification center
|
||||
let notification = UNNotificationRequest(
|
||||
identifier: notificationId,
|
||||
content: notificationContent,
|
||||
trigger: nil
|
||||
)
|
||||
let center = UNUserNotificationCenter.current()
|
||||
center.add(notification)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private func handleClearErrorNotifications() {
|
||||
let center = UNUserNotificationCenter.current()
|
||||
center.removeDeliveredNotifications(withIdentifiers: [notificationId])
|
||||
center.removePendingNotificationRequests(withIdentifiers: [notificationId])
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
<array>
|
||||
<string>app.alextran.immich.background.refreshUpload</string>
|
||||
<string>app.alextran.immich.background.processingUpload</string>
|
||||
<string>app.alextran.immich.backgroundFetch</string>
|
||||
<string>app.alextran.immich.backgroundProcessing</string>
|
||||
</array>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
|
||||
19
mobile/lib/constants/aspect_ratios.dart
Normal file
19
mobile/lib/constants/aspect_ratios.dart
Normal file
@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum AspectRatioPreset {
|
||||
free(ratio: null, label: 'Free', icon: Icons.crop_free_rounded),
|
||||
square(ratio: 1.0, label: '1:1', icon: Icons.crop_square_rounded),
|
||||
ratio16x9(ratio: 16 / 9, label: '16:9', icon: Icons.crop_16_9_rounded),
|
||||
ratio3x2(ratio: 3 / 2, label: '3:2', icon: Icons.crop_3_2_rounded),
|
||||
ratio7x5(ratio: 7 / 5, label: '7:5', icon: Icons.crop_7_5_rounded),
|
||||
ratio9x16(ratio: 9 / 16, label: '9:16', icon: Icons.crop_16_9_rounded, iconRotated: true),
|
||||
ratio2x3(ratio: 2 / 3, label: '2:3', icon: Icons.crop_3_2_rounded, iconRotated: true),
|
||||
ratio5x7(ratio: 5 / 7, label: '5:7', icon: Icons.crop_7_5_rounded, iconRotated: true);
|
||||
|
||||
final double? ratio;
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final bool iconRotated;
|
||||
|
||||
const AspectRatioPreset({required this.ratio, required this.label, required this.icon, this.iconRotated = false});
|
||||
}
|
||||
@ -1,9 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
const int noDbId = -9223372036854775808; // from Isar
|
||||
const double downloadCompleted = -1;
|
||||
const double downloadFailed = -2;
|
||||
|
||||
const String kMobileMetadataKey = "mobile-app";
|
||||
|
||||
// Number of log entries to retain on app start
|
||||
@ -47,9 +43,6 @@ const List<(String, String)> kWidgetNames = [
|
||||
('com.immich.widget.memory', 'app.alextran.immich.widget.MemoryReceiver'),
|
||||
];
|
||||
|
||||
const double kUploadStatusFailed = -1.0;
|
||||
const double kUploadStatusCanceled = -2.0;
|
||||
|
||||
const int kMinMonthsToEnableScrubberSnap = 12;
|
||||
|
||||
const String kImmichAppStoreLink = "https://apps.apple.com/app/immich/id1613945652";
|
||||
|
||||
@ -11,8 +11,6 @@ enum TextSearchType { context, filename, description, ocr }
|
||||
|
||||
enum AssetVisibilityEnum { timeline, hidden, archive, locked }
|
||||
|
||||
enum SortUserBy { id }
|
||||
|
||||
enum ActionSource { timeline, viewer }
|
||||
|
||||
enum CleanupStep { selectDate, scan, delete }
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
abstract interface class IDatabaseRepository {
|
||||
Future<T> transaction<T>(Future<T> Function() callback);
|
||||
}
|
||||
@ -71,6 +71,8 @@ sealed class BaseAsset {
|
||||
bool get isLocalOnly => storage == AssetState.local;
|
||||
bool get isRemoteOnly => storage == AssetState.remote;
|
||||
|
||||
bool get isEditable => false;
|
||||
|
||||
// Overridden in subclasses
|
||||
AssetState get storage;
|
||||
String? get localId;
|
||||
|
||||
@ -43,6 +43,9 @@ class RemoteAsset extends BaseAsset {
|
||||
@override
|
||||
String get heroTag => '${localId ?? checksum}_$id';
|
||||
|
||||
@override
|
||||
bool get isEditable => isImage && !isMotionPhoto && !isAnimatedImage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''Asset {
|
||||
|
||||
@ -1,21 +1,25 @@
|
||||
import "package:openapi/api.dart" as api show AssetEditAction;
|
||||
import "package:openapi/api.dart" show CropParameters, RotateParameters, MirrorParameters;
|
||||
|
||||
enum AssetEditAction { rotate, crop, mirror, other }
|
||||
|
||||
extension AssetEditActionExtension on AssetEditAction {
|
||||
api.AssetEditAction? toDto() {
|
||||
return switch (this) {
|
||||
AssetEditAction.rotate => api.AssetEditAction.rotate,
|
||||
AssetEditAction.crop => api.AssetEditAction.crop,
|
||||
AssetEditAction.mirror => api.AssetEditAction.mirror,
|
||||
AssetEditAction.other => null,
|
||||
};
|
||||
}
|
||||
sealed class AssetEdit {
|
||||
const AssetEdit();
|
||||
}
|
||||
|
||||
class AssetEdit {
|
||||
final AssetEditAction action;
|
||||
final Map<String, dynamic> parameters;
|
||||
class CropEdit extends AssetEdit {
|
||||
final CropParameters parameters;
|
||||
|
||||
const AssetEdit({required this.action, required this.parameters});
|
||||
const CropEdit(this.parameters);
|
||||
}
|
||||
|
||||
class RotateEdit extends AssetEdit {
|
||||
final RotateParameters parameters;
|
||||
|
||||
const RotateEdit(this.parameters);
|
||||
}
|
||||
|
||||
class MirrorEdit extends AssetEdit {
|
||||
final MirrorParameters parameters;
|
||||
|
||||
const MirrorEdit(this.parameters);
|
||||
}
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
class DeviceAsset {
|
||||
final String assetId;
|
||||
final Uint8List hash;
|
||||
final DateTime modifiedTime;
|
||||
|
||||
const DeviceAsset({required this.assetId, required this.hash, required this.modifiedTime});
|
||||
|
||||
@override
|
||||
bool operator ==(covariant DeviceAsset other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other.assetId == assetId && other.hash == hash && other.modifiedTime == modifiedTime;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return assetId.hashCode ^ hash.hashCode ^ modifiedTime.hashCode;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DeviceAsset(assetId: $assetId, hash: $hash, modifiedTime: $modifiedTime)';
|
||||
}
|
||||
|
||||
DeviceAsset copyWith({String? assetId, Uint8List? hash, DateTime? modifiedTime}) {
|
||||
return DeviceAsset(
|
||||
assetId: assetId ?? this.assetId,
|
||||
hash: hash ?? this.hash,
|
||||
modifiedTime: modifiedTime ?? this.modifiedTime,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,8 @@ class ExifInfo {
|
||||
final String? timeZone;
|
||||
final DateTime? dateTimeOriginal;
|
||||
final int? rating;
|
||||
final int? width;
|
||||
final int? height;
|
||||
|
||||
// GPS
|
||||
final double? latitude;
|
||||
@ -48,6 +50,8 @@ class ExifInfo {
|
||||
this.timeZone,
|
||||
this.dateTimeOriginal,
|
||||
this.rating,
|
||||
this.width,
|
||||
this.height,
|
||||
this.isFlipped = false,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
@ -74,6 +78,8 @@ class ExifInfo {
|
||||
other.timeZone == timeZone &&
|
||||
other.dateTimeOriginal == dateTimeOriginal &&
|
||||
other.rating == rating &&
|
||||
other.width == width &&
|
||||
other.height == height &&
|
||||
other.latitude == latitude &&
|
||||
other.longitude == longitude &&
|
||||
other.city == city &&
|
||||
@ -98,6 +104,8 @@ class ExifInfo {
|
||||
timeZone.hashCode ^
|
||||
dateTimeOriginal.hashCode ^
|
||||
rating.hashCode ^
|
||||
width.hashCode ^
|
||||
height.hashCode ^
|
||||
latitude.hashCode ^
|
||||
longitude.hashCode ^
|
||||
city.hashCode ^
|
||||
@ -123,6 +131,8 @@ isFlipped: $isFlipped,
|
||||
timeZone: ${timeZone ?? 'NA'},
|
||||
dateTimeOriginal: ${dateTimeOriginal ?? 'NA'},
|
||||
rating: ${rating ?? 'NA'},
|
||||
width: ${width ?? 'NA'},
|
||||
height: ${height ?? 'NA'},
|
||||
latitude: ${latitude ?? 'NA'},
|
||||
longitude: ${longitude ?? 'NA'},
|
||||
city: ${city ?? 'NA'},
|
||||
@ -146,6 +156,8 @@ exposureSeconds: ${exposureSeconds ?? 'NA'},
|
||||
String? timeZone,
|
||||
DateTime? dateTimeOriginal,
|
||||
int? rating,
|
||||
int? width,
|
||||
int? height,
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
String? city,
|
||||
@ -168,6 +180,8 @@ exposureSeconds: ${exposureSeconds ?? 'NA'},
|
||||
timeZone: timeZone ?? this.timeZone,
|
||||
dateTimeOriginal: dateTimeOriginal ?? this.dateTimeOriginal,
|
||||
rating: rating ?? this.rating,
|
||||
width: width ?? this.width,
|
||||
height: height ?? this.height,
|
||||
isFlipped: isFlipped ?? this.isFlipped,
|
||||
latitude: latitude ?? this.latitude,
|
||||
longitude: longitude ?? this.longitude,
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
import 'package:immich_mobile/domain/models/album/local_album.model.dart';
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||
import 'package:immich_mobile/extensions/platform_extensions.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/local_asset.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/remote_asset.repository.dart';
|
||||
|
||||
typedef _AssetVideoDimension = ({double? width, double? height, bool isFlipped});
|
||||
|
||||
class AssetService {
|
||||
final RemoteAssetRepository _remoteAssetRepository;
|
||||
final DriftLocalAssetRepository _localAssetRepository;
|
||||
@ -58,49 +55,6 @@ class AssetService {
|
||||
return _remoteAssetRepository.getExif(id);
|
||||
}
|
||||
|
||||
Future<double> getAspectRatio(BaseAsset asset) async {
|
||||
final dimension = asset is LocalAsset
|
||||
? await _getLocalAssetDimensions(asset)
|
||||
: await _getRemoteAssetDimensions(asset as RemoteAsset);
|
||||
|
||||
if (dimension.width == null || dimension.height == null || dimension.height == 0) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return dimension.isFlipped ? dimension.height! / dimension.width! : dimension.width! / dimension.height!;
|
||||
}
|
||||
|
||||
Future<_AssetVideoDimension> _getLocalAssetDimensions(LocalAsset asset) async {
|
||||
double? width = asset.width?.toDouble();
|
||||
double? height = asset.height?.toDouble();
|
||||
int orientation = asset.orientation;
|
||||
|
||||
if (width == null || height == null) {
|
||||
final fetched = await _localAssetRepository.get(asset.id);
|
||||
width = fetched?.width?.toDouble();
|
||||
height = fetched?.height?.toDouble();
|
||||
orientation = fetched?.orientation ?? 0;
|
||||
}
|
||||
|
||||
// On Android, local assets need orientation correction for 90°/270° rotations
|
||||
// On iOS, the Photos framework pre-corrects dimensions
|
||||
final isFlipped = CurrentPlatform.isAndroid && (orientation == 90 || orientation == 270);
|
||||
return (width: width, height: height, isFlipped: isFlipped);
|
||||
}
|
||||
|
||||
Future<_AssetVideoDimension> _getRemoteAssetDimensions(RemoteAsset asset) async {
|
||||
double? width = asset.width?.toDouble();
|
||||
double? height = asset.height?.toDouble();
|
||||
|
||||
if (width == null || height == null) {
|
||||
final fetched = await _remoteAssetRepository.get(asset.id);
|
||||
width = fetched?.width?.toDouble();
|
||||
height = fetched?.height?.toDouble();
|
||||
}
|
||||
|
||||
return (width: width, height: height, isFlipped: false);
|
||||
}
|
||||
|
||||
Future<List<(String, String)>> getPlaces(String userId) {
|
||||
return _remoteAssetRepository.getPlaces(userId);
|
||||
}
|
||||
|
||||
@ -16,19 +16,16 @@ import 'package:immich_mobile/platform/background_worker_lock_api.g.dart';
|
||||
import 'package:immich_mobile/providers/app_settings.provider.dart';
|
||||
import 'package:immich_mobile/providers/background_sync.provider.dart';
|
||||
import 'package:immich_mobile/providers/backup/drift_backup.provider.dart';
|
||||
import 'package:immich_mobile/providers/db.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/platform.provider.dart' show nativeSyncApiProvider;
|
||||
import 'package:immich_mobile/providers/user.provider.dart';
|
||||
import 'package:immich_mobile/repositories/file_media.repository.dart';
|
||||
import 'package:immich_mobile/services/app_settings.service.dart';
|
||||
import 'package:immich_mobile/services/auth.service.dart';
|
||||
import 'package:immich_mobile/services/localization.service.dart';
|
||||
import 'package:immich_mobile/services/foreground_upload.service.dart';
|
||||
import 'package:immich_mobile/services/localization.service.dart';
|
||||
import 'package:immich_mobile/utils/bootstrap.dart';
|
||||
import 'package:immich_mobile/utils/debug_print.dart';
|
||||
import 'package:immich_mobile/wm_executor.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class BackgroundWorkerFgService {
|
||||
@ -58,7 +55,6 @@ class BackgroundWorkerFgService {
|
||||
|
||||
class BackgroundWorkerBgService extends BackgroundWorkerFlutterApi {
|
||||
ProviderContainer? _ref;
|
||||
final Isar _isar;
|
||||
final Drift _drift;
|
||||
final DriftLogger _driftLogger;
|
||||
final BackgroundWorkerBgHostApi _backgroundHostApi;
|
||||
@ -67,18 +63,11 @@ class BackgroundWorkerBgService extends BackgroundWorkerFlutterApi {
|
||||
|
||||
bool _isCleanedUp = false;
|
||||
|
||||
BackgroundWorkerBgService({required Isar isar, required Drift drift, required DriftLogger driftLogger})
|
||||
: _isar = isar,
|
||||
_drift = drift,
|
||||
BackgroundWorkerBgService({required Drift drift, required DriftLogger driftLogger})
|
||||
: _drift = drift,
|
||||
_driftLogger = driftLogger,
|
||||
_backgroundHostApi = BackgroundWorkerBgHostApi() {
|
||||
_ref = ProviderContainer(
|
||||
overrides: [
|
||||
dbProvider.overrideWithValue(isar),
|
||||
isarProvider.overrideWithValue(isar),
|
||||
driftProvider.overrideWith(driftOverride(drift)),
|
||||
],
|
||||
);
|
||||
_ref = ProviderContainer(overrides: [driftProvider.overrideWith(driftOverride(drift))]);
|
||||
BackgroundWorkerFlutterApi.setUp(this);
|
||||
}
|
||||
|
||||
@ -102,7 +91,6 @@ class BackgroundWorkerBgService extends BackgroundWorkerFlutterApi {
|
||||
),
|
||||
FileDownloader().trackTasksInGroup(kDownloadGroupLivePhoto, markDownloadedComplete: false),
|
||||
FileDownloader().trackTasks(),
|
||||
_ref?.read(fileMediaRepositoryProvider).enableBackgroundAccess(),
|
||||
].nonNulls,
|
||||
);
|
||||
|
||||
@ -209,9 +197,6 @@ class BackgroundWorkerBgService extends BackgroundWorkerFlutterApi {
|
||||
backgroundSyncManager?.cancel(),
|
||||
];
|
||||
|
||||
if (_isar.isOpen) {
|
||||
cleanupFutures.add(_isar.close());
|
||||
}
|
||||
await Future.wait(cleanupFutures.nonNulls);
|
||||
_logger.info("Background worker resources cleaned up");
|
||||
} catch (error, stack) {
|
||||
@ -301,7 +286,6 @@ Future<void> backgroundSyncNativeEntrypoint() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
DartPluginRegistrant.ensureInitialized();
|
||||
|
||||
final (isar, drift, logDB) = await Bootstrap.initDB();
|
||||
await Bootstrap.initDomain(isar, drift, logDB, shouldBufferLogs: false, listenStoreUpdates: false);
|
||||
await BackgroundWorkerBgService(isar: isar, drift: drift, driftLogger: logDB).init();
|
||||
final (drift, logDB) = await Bootstrap.initDomain(shouldBufferLogs: false, listenStoreUpdates: false);
|
||||
await BackgroundWorkerBgService(drift: drift, driftLogger: logDB).init();
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ import 'package:logging/logging.dart';
|
||||
/// via [IStoreRepository]
|
||||
class LogService {
|
||||
final LogRepository _logRepository;
|
||||
final IStoreRepository _storeRepository;
|
||||
final DriftStoreRepository _storeRepository;
|
||||
|
||||
final List<LogMessage> _msgBuffer = [];
|
||||
|
||||
@ -38,7 +38,7 @@ class LogService {
|
||||
|
||||
static Future<LogService> init({
|
||||
required LogRepository logRepository,
|
||||
required IStoreRepository storeRepository,
|
||||
required DriftStoreRepository storeRepository,
|
||||
bool shouldBuffer = true,
|
||||
}) async {
|
||||
_instance ??= await create(
|
||||
@ -51,7 +51,7 @@ class LogService {
|
||||
|
||||
static Future<LogService> create({
|
||||
required LogRepository logRepository,
|
||||
required IStoreRepository storeRepository,
|
||||
required DriftStoreRepository storeRepository,
|
||||
bool shouldBuffer = true,
|
||||
}) async {
|
||||
final instance = LogService._(logRepository, storeRepository, shouldBuffer);
|
||||
|
||||
@ -6,13 +6,13 @@ import 'package:immich_mobile/infrastructure/repositories/store.repository.dart'
|
||||
/// Provides access to a persistent key-value store with an in-memory cache.
|
||||
/// Listens for repository changes to keep the cache updated.
|
||||
class StoreService {
|
||||
final IStoreRepository _storeRepository;
|
||||
final DriftStoreRepository _storeRepository;
|
||||
|
||||
/// In-memory cache. Keys are [StoreKey.id]
|
||||
final Map<int, Object?> _cache = {};
|
||||
StreamSubscription<List<StoreDto>>? _storeUpdateSubscription;
|
||||
|
||||
StoreService._({required IStoreRepository isarStoreRepository}) : _storeRepository = isarStoreRepository;
|
||||
StoreService._({required DriftStoreRepository isarStoreRepository}) : _storeRepository = isarStoreRepository;
|
||||
|
||||
// TODO: Temporary typedef to make minimal changes. Remove this and make the presentation layer access store through a provider
|
||||
static StoreService? _instance;
|
||||
@ -24,12 +24,12 @@ class StoreService {
|
||||
}
|
||||
|
||||
// TODO: Replace the implementation with the one from create after removing the typedef
|
||||
static Future<StoreService> init({required IStoreRepository storeRepository, bool listenUpdates = true}) async {
|
||||
static Future<StoreService> init({required DriftStoreRepository storeRepository, bool listenUpdates = true}) async {
|
||||
_instance ??= await create(storeRepository: storeRepository, listenUpdates: listenUpdates);
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
static Future<StoreService> create({required IStoreRepository storeRepository, bool listenUpdates = true}) async {
|
||||
static Future<StoreService> create({required DriftStoreRepository storeRepository, bool listenUpdates = true}) async {
|
||||
final instance = StoreService._(isarStoreRepository: storeRepository);
|
||||
await instance.populateCache();
|
||||
if (listenUpdates) {
|
||||
@ -91,8 +91,6 @@ class StoreService {
|
||||
await _storeRepository.deleteAll();
|
||||
_cache.clear();
|
||||
}
|
||||
|
||||
bool get isBetaTimelineEnabled => tryGet(StoreKey.betaTimeline) ?? true;
|
||||
}
|
||||
|
||||
class StoreKeyNotFoundException implements Exception {
|
||||
|
||||
@ -4,23 +4,17 @@ import 'dart:typed_data';
|
||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
import 'package:immich_mobile/domain/services/store.service.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/user.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/user_api.repository.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class UserService {
|
||||
final Logger _log = Logger("UserService");
|
||||
final IsarUserRepository _isarUserRepository;
|
||||
final UserApiRepository _userApiRepository;
|
||||
final StoreService _storeService;
|
||||
|
||||
UserService({
|
||||
required IsarUserRepository isarUserRepository,
|
||||
required UserApiRepository userApiRepository,
|
||||
required StoreService storeService,
|
||||
}) : _isarUserRepository = isarUserRepository,
|
||||
_userApiRepository = userApiRepository,
|
||||
_storeService = storeService;
|
||||
UserService({required UserApiRepository userApiRepository, required StoreService storeService})
|
||||
: _userApiRepository = userApiRepository,
|
||||
_storeService = storeService;
|
||||
|
||||
UserDto getMyUser() {
|
||||
return _storeService.get(StoreKey.currentUser);
|
||||
@ -38,7 +32,6 @@ class UserService {
|
||||
final user = await _userApiRepository.getMyUser();
|
||||
if (user == null) return null;
|
||||
await _storeService.put(StoreKey.currentUser, user);
|
||||
await _isarUserRepository.update(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@ -47,19 +40,10 @@ class UserService {
|
||||
final path = await _userApiRepository.createProfileImage(name: name, data: image);
|
||||
final updatedUser = getMyUser();
|
||||
await _storeService.put(StoreKey.currentUser, updatedUser);
|
||||
await _isarUserRepository.update(updatedUser);
|
||||
return path;
|
||||
} catch (e) {
|
||||
_log.warning("Failed to upload profile image", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<UserDto>> getAll() async {
|
||||
return await _isarUserRepository.getAll();
|
||||
}
|
||||
|
||||
Future<void> deleteAll() {
|
||||
return _isarUserRepository.deleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,12 +80,14 @@ Future<void> _processCloudIdMappingsInBatches(
|
||||
AssetMetadataBulkUpsertItemDto(
|
||||
assetId: mapping.remoteAssetId,
|
||||
key: kMobileMetadataKey,
|
||||
value: RemoteAssetMobileAppMetadata(
|
||||
cloudId: mapping.localAsset.cloudId,
|
||||
createdAt: mapping.localAsset.createdAt.toIso8601String(),
|
||||
adjustmentTime: mapping.localAsset.adjustmentTime?.toIso8601String(),
|
||||
latitude: mapping.localAsset.latitude?.toString(),
|
||||
longitude: mapping.localAsset.longitude?.toString(),
|
||||
value: Map<String, Object>.from(
|
||||
RemoteAssetMobileAppMetadata(
|
||||
cloudId: mapping.localAsset.cloudId,
|
||||
createdAt: mapping.localAsset.createdAt.toIso8601String(),
|
||||
adjustmentTime: mapping.localAsset.adjustmentTime?.toIso8601String(),
|
||||
latitude: mapping.localAsset.latitude?.toString(),
|
||||
longitude: mapping.localAsset.longitude?.toString(),
|
||||
).toJson(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -1 +0,0 @@
|
||||
This directory contains entity that is stored in the local storage.
|
||||
@ -1,192 +0,0 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
||||
import 'package:immich_mobile/utils/datetime_comparison.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:isar/src/common/isar_links_common.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
part 'album.entity.g.dart';
|
||||
|
||||
@Collection(inheritance: false)
|
||||
class Album {
|
||||
@protected
|
||||
Album({
|
||||
this.remoteId,
|
||||
this.localId,
|
||||
required this.name,
|
||||
required this.createdAt,
|
||||
required this.modifiedAt,
|
||||
this.description,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.lastModifiedAssetTimestamp,
|
||||
required this.shared,
|
||||
required this.activityEnabled,
|
||||
this.sortOrder = SortOrder.desc,
|
||||
});
|
||||
|
||||
// fields stored in DB
|
||||
Id id = Isar.autoIncrement;
|
||||
@Index(unique: false, replace: false, type: IndexType.hash)
|
||||
String? remoteId;
|
||||
@Index(unique: false, replace: false, type: IndexType.hash)
|
||||
String? localId;
|
||||
String name;
|
||||
String? description;
|
||||
DateTime createdAt;
|
||||
DateTime modifiedAt;
|
||||
DateTime? startDate;
|
||||
DateTime? endDate;
|
||||
DateTime? lastModifiedAssetTimestamp;
|
||||
bool shared;
|
||||
bool activityEnabled;
|
||||
@enumerated
|
||||
SortOrder sortOrder;
|
||||
final IsarLink<User> owner = IsarLink<User>();
|
||||
final IsarLink<Asset> thumbnail = IsarLink<Asset>();
|
||||
final IsarLinks<User> sharedUsers = IsarLinks<User>();
|
||||
final IsarLinks<Asset> assets = IsarLinks<Asset>();
|
||||
|
||||
// transient fields
|
||||
@ignore
|
||||
bool isAll = false;
|
||||
|
||||
@ignore
|
||||
String? remoteThumbnailAssetId;
|
||||
|
||||
@ignore
|
||||
int remoteAssetCount = 0;
|
||||
|
||||
// getters
|
||||
@ignore
|
||||
bool get isRemote => remoteId != null;
|
||||
|
||||
@ignore
|
||||
bool get isLocal => localId != null;
|
||||
|
||||
@ignore
|
||||
int get assetCount => assets.length;
|
||||
|
||||
@ignore
|
||||
String? get ownerId => owner.value?.id;
|
||||
|
||||
@ignore
|
||||
String? get ownerName {
|
||||
// Guard null owner
|
||||
if (owner.value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final name = <String>[];
|
||||
if (owner.value?.name != null) {
|
||||
name.add(owner.value!.name);
|
||||
}
|
||||
|
||||
return name.join(' ');
|
||||
}
|
||||
|
||||
@ignore
|
||||
String get eTagKeyAssetCount => "device-album-$localId-asset-count";
|
||||
|
||||
// the following getter are needed because Isar links do not make data
|
||||
// accessible in an object freshly created (not loaded from DB)
|
||||
|
||||
@ignore
|
||||
Iterable<User> get remoteUsers =>
|
||||
sharedUsers.isEmpty ? (sharedUsers as IsarLinksCommon<User>).addedObjects : sharedUsers;
|
||||
|
||||
@ignore
|
||||
Iterable<Asset> get remoteAssets => assets.isEmpty ? (assets as IsarLinksCommon<Asset>).addedObjects : assets;
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (other is! Album) return false;
|
||||
return id == other.id &&
|
||||
remoteId == other.remoteId &&
|
||||
localId == other.localId &&
|
||||
name == other.name &&
|
||||
description == other.description &&
|
||||
createdAt.isAtSameMomentAs(other.createdAt) &&
|
||||
modifiedAt.isAtSameMomentAs(other.modifiedAt) &&
|
||||
isAtSameMomentAs(startDate, other.startDate) &&
|
||||
isAtSameMomentAs(endDate, other.endDate) &&
|
||||
isAtSameMomentAs(lastModifiedAssetTimestamp, other.lastModifiedAssetTimestamp) &&
|
||||
shared == other.shared &&
|
||||
activityEnabled == other.activityEnabled &&
|
||||
owner.value == other.owner.value &&
|
||||
thumbnail.value == other.thumbnail.value &&
|
||||
sharedUsers.length == other.sharedUsers.length &&
|
||||
assets.length == other.assets.length;
|
||||
}
|
||||
|
||||
@override
|
||||
@ignore
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
remoteId.hashCode ^
|
||||
localId.hashCode ^
|
||||
name.hashCode ^
|
||||
createdAt.hashCode ^
|
||||
modifiedAt.hashCode ^
|
||||
startDate.hashCode ^
|
||||
endDate.hashCode ^
|
||||
description.hashCode ^
|
||||
lastModifiedAssetTimestamp.hashCode ^
|
||||
shared.hashCode ^
|
||||
activityEnabled.hashCode ^
|
||||
owner.value.hashCode ^
|
||||
thumbnail.value.hashCode ^
|
||||
sharedUsers.length.hashCode ^
|
||||
assets.length.hashCode;
|
||||
|
||||
static Future<Album> remote(AlbumResponseDto dto) async {
|
||||
final Isar db = Isar.getInstance()!;
|
||||
final Album a = Album(
|
||||
remoteId: dto.id,
|
||||
name: dto.albumName,
|
||||
createdAt: dto.createdAt,
|
||||
modifiedAt: dto.updatedAt,
|
||||
description: dto.description,
|
||||
lastModifiedAssetTimestamp: dto.lastModifiedAssetTimestamp,
|
||||
shared: dto.shared,
|
||||
startDate: dto.startDate,
|
||||
endDate: dto.endDate,
|
||||
activityEnabled: dto.isActivityEnabled,
|
||||
);
|
||||
a.remoteAssetCount = dto.assetCount;
|
||||
a.owner.value = await db.users.getById(dto.ownerId);
|
||||
if (dto.order != null) {
|
||||
a.sortOrder = dto.order == AssetOrder.asc ? SortOrder.asc : SortOrder.desc;
|
||||
}
|
||||
|
||||
if (dto.albumThumbnailAssetId != null) {
|
||||
a.thumbnail.value = await db.assets.where().remoteIdEqualTo(dto.albumThumbnailAssetId).findFirst();
|
||||
}
|
||||
if (dto.albumUsers.isNotEmpty) {
|
||||
final users = await db.users.getAllById(dto.albumUsers.map((e) => e.user.id).toList(growable: false));
|
||||
a.sharedUsers.addAll(users.cast());
|
||||
}
|
||||
if (dto.assets.isNotEmpty) {
|
||||
final assets = await db.assets.getAllByRemoteId(dto.assets.map((e) => e.id));
|
||||
a.assets.addAll(assets);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'remoteId: $remoteId name: $name description: $description';
|
||||
}
|
||||
|
||||
extension AssetsHelper on IsarCollection<Album> {
|
||||
Future<Album> store(Album a) async {
|
||||
await put(a);
|
||||
await a.owner.save();
|
||||
await a.thumbnail.save();
|
||||
await a.sharedUsers.save();
|
||||
await a.assets.save();
|
||||
return a;
|
||||
}
|
||||
}
|
||||
2240
mobile/lib/entities/album.entity.g.dart
generated
2240
mobile/lib/entities/album.entity.g.dart
generated
File diff suppressed because it is too large
Load Diff
@ -1,10 +0,0 @@
|
||||
import 'package:immich_mobile/entities/device_asset.entity.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'android_device_asset.entity.g.dart';
|
||||
|
||||
@Collection()
|
||||
class AndroidDeviceAsset extends DeviceAsset {
|
||||
AndroidDeviceAsset({required this.id, required super.hash});
|
||||
Id id;
|
||||
}
|
||||
463
mobile/lib/entities/android_device_asset.entity.g.dart
generated
463
mobile/lib/entities/android_device_asset.entity.g.dart
generated
@ -1,463 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'android_device_asset.entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types
|
||||
|
||||
extension GetAndroidDeviceAssetCollection on Isar {
|
||||
IsarCollection<AndroidDeviceAsset> get androidDeviceAssets =>
|
||||
this.collection();
|
||||
}
|
||||
|
||||
const AndroidDeviceAssetSchema = CollectionSchema(
|
||||
name: r'AndroidDeviceAsset',
|
||||
id: -6758387181232899335,
|
||||
properties: {
|
||||
r'hash': PropertySchema(id: 0, name: r'hash', type: IsarType.byteList),
|
||||
},
|
||||
|
||||
estimateSize: _androidDeviceAssetEstimateSize,
|
||||
serialize: _androidDeviceAssetSerialize,
|
||||
deserialize: _androidDeviceAssetDeserialize,
|
||||
deserializeProp: _androidDeviceAssetDeserializeProp,
|
||||
idName: r'id',
|
||||
indexes: {
|
||||
r'hash': IndexSchema(
|
||||
id: -7973251393006690288,
|
||||
name: r'hash',
|
||||
unique: false,
|
||||
replace: false,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'hash',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
},
|
||||
links: {},
|
||||
embeddedSchemas: {},
|
||||
|
||||
getId: _androidDeviceAssetGetId,
|
||||
getLinks: _androidDeviceAssetGetLinks,
|
||||
attach: _androidDeviceAssetAttach,
|
||||
version: '3.3.0-dev.3',
|
||||
);
|
||||
|
||||
int _androidDeviceAssetEstimateSize(
|
||||
AndroidDeviceAsset object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.hash.length;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _androidDeviceAssetSerialize(
|
||||
AndroidDeviceAsset object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeByteList(offsets[0], object.hash);
|
||||
}
|
||||
|
||||
AndroidDeviceAsset _androidDeviceAssetDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = AndroidDeviceAsset(
|
||||
hash: reader.readByteList(offsets[0]) ?? [],
|
||||
id: id,
|
||||
);
|
||||
return object;
|
||||
}
|
||||
|
||||
P _androidDeviceAssetDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readByteList(offset) ?? []) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _androidDeviceAssetGetId(AndroidDeviceAsset object) {
|
||||
return object.id;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _androidDeviceAssetGetLinks(
|
||||
AndroidDeviceAsset object,
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
void _androidDeviceAssetAttach(
|
||||
IsarCollection<dynamic> col,
|
||||
Id id,
|
||||
AndroidDeviceAsset object,
|
||||
) {
|
||||
object.id = id;
|
||||
}
|
||||
|
||||
extension AndroidDeviceAssetQueryWhereSort
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QWhere> {
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhere> anyId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension AndroidDeviceAssetQueryWhere
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QWhereClause> {
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhereClause>
|
||||
idEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IdWhereClause.between(lower: id, upper: id));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhereClause>
|
||||
idNotEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhereClause>
|
||||
idGreaterThan(Id id, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhereClause>
|
||||
idLessThan(Id id, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhereClause>
|
||||
idBetween(
|
||||
Id lowerId,
|
||||
Id upperId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(
|
||||
lower: lowerId,
|
||||
includeLower: includeLower,
|
||||
upper: upperId,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhereClause>
|
||||
hashEqualTo(List<int> hash) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IndexWhereClause.equalTo(indexName: r'hash', value: [hash]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterWhereClause>
|
||||
hashNotEqualTo(List<int> hash) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [],
|
||||
upper: [hash],
|
||||
includeUpper: false,
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [hash],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [hash],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [],
|
||||
upper: [hash],
|
||||
includeUpper: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension AndroidDeviceAssetQueryFilter
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QFilterCondition> {
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashElementEqualTo(int value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'hash', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashElementGreaterThan(int value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'hash',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashElementLessThan(int value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'hash',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashElementBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'hash',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthEqualTo(int length) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', length, true, length, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, false, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthLessThan(int length, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, true, length, include);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthGreaterThan(int length, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', length, include, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'hash',
|
||||
lower,
|
||||
includeLower,
|
||||
upper,
|
||||
includeUpper,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
idEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'id', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
idGreaterThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
idLessThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterFilterCondition>
|
||||
idBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension AndroidDeviceAssetQueryObject
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QFilterCondition> {}
|
||||
|
||||
extension AndroidDeviceAssetQueryLinks
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QFilterCondition> {}
|
||||
|
||||
extension AndroidDeviceAssetQuerySortBy
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QSortBy> {}
|
||||
|
||||
extension AndroidDeviceAssetQuerySortThenBy
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QSortThenBy> {
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterSortBy>
|
||||
thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QAfterSortBy>
|
||||
thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension AndroidDeviceAssetQueryWhereDistinct
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QDistinct> {
|
||||
QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QDistinct>
|
||||
distinctByHash() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'hash');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension AndroidDeviceAssetQueryProperty
|
||||
on QueryBuilder<AndroidDeviceAsset, AndroidDeviceAsset, QQueryProperty> {
|
||||
QueryBuilder<AndroidDeviceAsset, int, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<AndroidDeviceAsset, List<int>, QQueryOperations> hashProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'hash');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,575 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||
import 'package:immich_mobile/extensions/string_extensions.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart' as entity;
|
||||
import 'package:immich_mobile/infrastructure/utils/exif.converter.dart';
|
||||
import 'package:immich_mobile/utils/diff.dart';
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:photo_manager/photo_manager.dart' show AssetEntity;
|
||||
|
||||
part 'asset.entity.g.dart';
|
||||
|
||||
/// Asset (online or local)
|
||||
@Collection(inheritance: false)
|
||||
class Asset {
|
||||
Asset.remote(AssetResponseDto remote)
|
||||
: remoteId = remote.id,
|
||||
checksum = remote.checksum,
|
||||
fileCreatedAt = remote.fileCreatedAt,
|
||||
fileModifiedAt = remote.fileModifiedAt,
|
||||
updatedAt = remote.updatedAt,
|
||||
durationInSeconds = remote.duration.toDuration()?.inSeconds ?? 0,
|
||||
type = remote.type.toAssetType(),
|
||||
fileName = remote.originalFileName,
|
||||
height = remote.exifInfo?.exifImageHeight?.toInt(),
|
||||
width = remote.exifInfo?.exifImageWidth?.toInt(),
|
||||
livePhotoVideoId = remote.livePhotoVideoId,
|
||||
ownerId = fastHash(remote.ownerId),
|
||||
exifInfo = remote.exifInfo == null ? null : ExifDtoConverter.fromDto(remote.exifInfo!),
|
||||
isFavorite = remote.isFavorite,
|
||||
isArchived = remote.isArchived,
|
||||
isTrashed = remote.isTrashed,
|
||||
isOffline = remote.isOffline,
|
||||
// workaround to nullify stackPrimaryAssetId for the parent asset until we refactor the mobile app
|
||||
// stack handling to properly handle it
|
||||
stackPrimaryAssetId = remote.stack?.primaryAssetId == remote.id ? null : remote.stack?.primaryAssetId,
|
||||
stackCount = remote.stack?.assetCount ?? 0,
|
||||
stackId = remote.stack?.id,
|
||||
thumbhash = remote.thumbhash,
|
||||
visibility = getVisibility(remote.visibility);
|
||||
|
||||
Asset({
|
||||
this.id = Isar.autoIncrement,
|
||||
required this.checksum,
|
||||
this.remoteId,
|
||||
required this.localId,
|
||||
required this.ownerId,
|
||||
required this.fileCreatedAt,
|
||||
required this.fileModifiedAt,
|
||||
required this.updatedAt,
|
||||
required this.durationInSeconds,
|
||||
required this.type,
|
||||
this.width,
|
||||
this.height,
|
||||
required this.fileName,
|
||||
this.livePhotoVideoId,
|
||||
this.exifInfo,
|
||||
this.isFavorite = false,
|
||||
this.isArchived = false,
|
||||
this.isTrashed = false,
|
||||
this.stackId,
|
||||
this.stackPrimaryAssetId,
|
||||
this.stackCount = 0,
|
||||
this.isOffline = false,
|
||||
this.thumbhash,
|
||||
this.visibility = AssetVisibilityEnum.timeline,
|
||||
});
|
||||
|
||||
@ignore
|
||||
AssetEntity? _local;
|
||||
|
||||
@ignore
|
||||
AssetEntity? get local {
|
||||
if (isLocal && _local == null) {
|
||||
_local = AssetEntity(
|
||||
id: localId!,
|
||||
typeInt: isImage ? 1 : 2,
|
||||
width: width ?? 0,
|
||||
height: height ?? 0,
|
||||
duration: durationInSeconds,
|
||||
createDateSecond: fileCreatedAt.millisecondsSinceEpoch ~/ 1000,
|
||||
modifiedDateSecond: fileModifiedAt.millisecondsSinceEpoch ~/ 1000,
|
||||
title: fileName,
|
||||
);
|
||||
}
|
||||
return _local;
|
||||
}
|
||||
|
||||
set local(AssetEntity? assetEntity) => _local = assetEntity;
|
||||
|
||||
@ignore
|
||||
bool _didUpdateLocal = false;
|
||||
|
||||
@ignore
|
||||
Future<AssetEntity> get localAsync async {
|
||||
final local = this.local;
|
||||
if (local == null) {
|
||||
throw Exception('Asset $fileName has no local data');
|
||||
}
|
||||
|
||||
final updatedLocal = _didUpdateLocal ? local : await local.obtainForNewProperties();
|
||||
if (updatedLocal == null) {
|
||||
throw Exception('Could not fetch local data for $fileName');
|
||||
}
|
||||
|
||||
this.local = updatedLocal;
|
||||
_didUpdateLocal = true;
|
||||
return updatedLocal;
|
||||
}
|
||||
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
/// stores the raw SHA1 bytes as a base64 String
|
||||
/// because Isar cannot sort lists of byte arrays
|
||||
String checksum;
|
||||
|
||||
String? thumbhash;
|
||||
|
||||
@Index(unique: false, replace: false, type: IndexType.hash)
|
||||
String? remoteId;
|
||||
|
||||
@Index(unique: false, replace: false, type: IndexType.hash)
|
||||
String? localId;
|
||||
|
||||
@Index(unique: true, replace: false, composite: [CompositeIndex("checksum", type: IndexType.hash)])
|
||||
int ownerId;
|
||||
|
||||
DateTime fileCreatedAt;
|
||||
|
||||
DateTime fileModifiedAt;
|
||||
|
||||
DateTime updatedAt;
|
||||
|
||||
int durationInSeconds;
|
||||
|
||||
@Enumerated(EnumType.ordinal)
|
||||
AssetType type;
|
||||
|
||||
short? width;
|
||||
|
||||
short? height;
|
||||
|
||||
String fileName;
|
||||
|
||||
String? livePhotoVideoId;
|
||||
|
||||
bool isFavorite;
|
||||
|
||||
bool isArchived;
|
||||
|
||||
bool isTrashed;
|
||||
|
||||
bool isOffline;
|
||||
|
||||
@ignore
|
||||
ExifInfo? exifInfo;
|
||||
|
||||
String? stackId;
|
||||
|
||||
String? stackPrimaryAssetId;
|
||||
|
||||
int stackCount;
|
||||
|
||||
@Enumerated(EnumType.ordinal)
|
||||
AssetVisibilityEnum visibility;
|
||||
|
||||
/// Returns null if the asset has no sync access to the exif info
|
||||
@ignore
|
||||
double? get aspectRatio {
|
||||
final orientatedWidth = this.orientatedWidth;
|
||||
final orientatedHeight = this.orientatedHeight;
|
||||
|
||||
if (orientatedWidth != null && orientatedHeight != null && orientatedWidth > 0 && orientatedHeight > 0) {
|
||||
return orientatedWidth.toDouble() / orientatedHeight.toDouble();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// `true` if this [Asset] is present on the device
|
||||
@ignore
|
||||
bool get isLocal => localId != null;
|
||||
|
||||
@ignore
|
||||
bool get isInDb => id != Isar.autoIncrement;
|
||||
|
||||
@ignore
|
||||
String get name => p.withoutExtension(fileName);
|
||||
|
||||
/// `true` if this [Asset] is present on the server
|
||||
@ignore
|
||||
bool get isRemote => remoteId != null;
|
||||
|
||||
@ignore
|
||||
bool get isImage => type == AssetType.image;
|
||||
|
||||
@ignore
|
||||
bool get isVideo => type == AssetType.video;
|
||||
|
||||
@ignore
|
||||
bool get isMotionPhoto => livePhotoVideoId != null;
|
||||
|
||||
@ignore
|
||||
AssetState get storage {
|
||||
if (isRemote && isLocal) {
|
||||
return AssetState.merged;
|
||||
} else if (isRemote) {
|
||||
return AssetState.remote;
|
||||
} else if (isLocal) {
|
||||
return AssetState.local;
|
||||
} else {
|
||||
throw Exception("Asset has illegal state: $this");
|
||||
}
|
||||
}
|
||||
|
||||
@ignore
|
||||
Duration get duration => Duration(seconds: durationInSeconds);
|
||||
|
||||
// ignore: invalid_annotation_target
|
||||
@ignore
|
||||
set byteHash(List<int> hash) => checksum = base64.encode(hash);
|
||||
|
||||
/// Returns null if the asset has no sync access to the exif info
|
||||
@ignore
|
||||
@pragma('vm:prefer-inline')
|
||||
bool? get isFlipped {
|
||||
final exifInfo = this.exifInfo;
|
||||
if (exifInfo != null) {
|
||||
return exifInfo.isFlipped;
|
||||
}
|
||||
|
||||
if (_didUpdateLocal && Platform.isAndroid) {
|
||||
final local = this.local;
|
||||
if (local == null) {
|
||||
throw Exception('Asset $fileName has no local data');
|
||||
}
|
||||
return local.orientation == 90 || local.orientation == 270;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Returns null if the asset has no sync access to the exif info
|
||||
@ignore
|
||||
@pragma('vm:prefer-inline')
|
||||
int? get orientatedHeight {
|
||||
final isFlipped = this.isFlipped;
|
||||
if (isFlipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return isFlipped ? width : height;
|
||||
}
|
||||
|
||||
/// Returns null if the asset has no sync access to the exif info
|
||||
@ignore
|
||||
@pragma('vm:prefer-inline')
|
||||
int? get orientatedWidth {
|
||||
final isFlipped = this.isFlipped;
|
||||
if (isFlipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return isFlipped ? height : width;
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (other is! Asset) return false;
|
||||
if (identical(this, other)) return true;
|
||||
return id == other.id &&
|
||||
checksum == other.checksum &&
|
||||
remoteId == other.remoteId &&
|
||||
localId == other.localId &&
|
||||
ownerId == other.ownerId &&
|
||||
fileCreatedAt.isAtSameMomentAs(other.fileCreatedAt) &&
|
||||
fileModifiedAt.isAtSameMomentAs(other.fileModifiedAt) &&
|
||||
updatedAt.isAtSameMomentAs(other.updatedAt) &&
|
||||
durationInSeconds == other.durationInSeconds &&
|
||||
type == other.type &&
|
||||
width == other.width &&
|
||||
height == other.height &&
|
||||
fileName == other.fileName &&
|
||||
livePhotoVideoId == other.livePhotoVideoId &&
|
||||
isFavorite == other.isFavorite &&
|
||||
isLocal == other.isLocal &&
|
||||
isArchived == other.isArchived &&
|
||||
isTrashed == other.isTrashed &&
|
||||
stackCount == other.stackCount &&
|
||||
stackPrimaryAssetId == other.stackPrimaryAssetId &&
|
||||
stackId == other.stackId;
|
||||
}
|
||||
|
||||
@override
|
||||
@ignore
|
||||
int get hashCode =>
|
||||
id.hashCode ^
|
||||
checksum.hashCode ^
|
||||
remoteId.hashCode ^
|
||||
localId.hashCode ^
|
||||
ownerId.hashCode ^
|
||||
fileCreatedAt.hashCode ^
|
||||
fileModifiedAt.hashCode ^
|
||||
updatedAt.hashCode ^
|
||||
durationInSeconds.hashCode ^
|
||||
type.hashCode ^
|
||||
width.hashCode ^
|
||||
height.hashCode ^
|
||||
fileName.hashCode ^
|
||||
livePhotoVideoId.hashCode ^
|
||||
isFavorite.hashCode ^
|
||||
isLocal.hashCode ^
|
||||
isArchived.hashCode ^
|
||||
isTrashed.hashCode ^
|
||||
stackCount.hashCode ^
|
||||
stackPrimaryAssetId.hashCode ^
|
||||
stackId.hashCode;
|
||||
|
||||
/// Returns `true` if this [Asset] can updated with values from parameter [a]
|
||||
bool canUpdate(Asset a) {
|
||||
assert(isInDb);
|
||||
assert(checksum == a.checksum);
|
||||
assert(a.storage != AssetState.merged);
|
||||
return a.updatedAt.isAfter(updatedAt) ||
|
||||
a.isRemote && !isRemote ||
|
||||
a.isLocal && !isLocal ||
|
||||
width == null && a.width != null ||
|
||||
height == null && a.height != null ||
|
||||
livePhotoVideoId == null && a.livePhotoVideoId != null ||
|
||||
isFavorite != a.isFavorite ||
|
||||
isArchived != a.isArchived ||
|
||||
isTrashed != a.isTrashed ||
|
||||
isOffline != a.isOffline ||
|
||||
a.exifInfo?.latitude != exifInfo?.latitude ||
|
||||
a.exifInfo?.longitude != exifInfo?.longitude ||
|
||||
// no local stack count or different count from remote
|
||||
a.thumbhash != thumbhash ||
|
||||
stackId != a.stackId ||
|
||||
stackCount != a.stackCount ||
|
||||
stackPrimaryAssetId == null && a.stackPrimaryAssetId != null ||
|
||||
visibility != a.visibility;
|
||||
}
|
||||
|
||||
/// Returns a new [Asset] with values from this and merged & updated with [a]
|
||||
Asset updatedCopy(Asset a) {
|
||||
assert(canUpdate(a));
|
||||
if (a.updatedAt.isAfter(updatedAt)) {
|
||||
// take most values from newer asset
|
||||
// keep vales that can never be set by the asset not in DB
|
||||
if (a.isRemote) {
|
||||
return a.copyWith(
|
||||
id: id,
|
||||
localId: localId,
|
||||
width: a.width ?? width,
|
||||
height: a.height ?? height,
|
||||
exifInfo: a.exifInfo?.copyWith(assetId: id) ?? exifInfo,
|
||||
);
|
||||
} else if (isRemote) {
|
||||
return copyWith(
|
||||
localId: localId ?? a.localId,
|
||||
width: width ?? a.width,
|
||||
height: height ?? a.height,
|
||||
exifInfo: exifInfo ?? a.exifInfo?.copyWith(assetId: id),
|
||||
);
|
||||
} else {
|
||||
// TODO: Revisit this and remove all bool field assignments
|
||||
return a.copyWith(
|
||||
id: id,
|
||||
remoteId: remoteId,
|
||||
livePhotoVideoId: livePhotoVideoId,
|
||||
// workaround to nullify stackPrimaryAssetId for the parent asset until we refactor the mobile app
|
||||
// stack handling to properly handle it
|
||||
stackId: stackId,
|
||||
stackPrimaryAssetId: stackPrimaryAssetId == remoteId ? null : stackPrimaryAssetId,
|
||||
stackCount: stackCount,
|
||||
isFavorite: isFavorite,
|
||||
isArchived: isArchived,
|
||||
isTrashed: isTrashed,
|
||||
isOffline: isOffline,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// fill in potentially missing values, i.e. merge assets
|
||||
if (a.isRemote) {
|
||||
// values from remote take precedence
|
||||
return copyWith(
|
||||
remoteId: a.remoteId,
|
||||
width: a.width,
|
||||
height: a.height,
|
||||
livePhotoVideoId: a.livePhotoVideoId,
|
||||
// workaround to nullify stackPrimaryAssetId for the parent asset until we refactor the mobile app
|
||||
// stack handling to properly handle it
|
||||
stackId: a.stackId,
|
||||
stackPrimaryAssetId: a.stackPrimaryAssetId == a.remoteId ? null : a.stackPrimaryAssetId,
|
||||
stackCount: a.stackCount,
|
||||
// isFavorite + isArchived are not set by device-only assets
|
||||
isFavorite: a.isFavorite,
|
||||
isArchived: a.isArchived,
|
||||
isTrashed: a.isTrashed,
|
||||
isOffline: a.isOffline,
|
||||
exifInfo: a.exifInfo?.copyWith(assetId: id) ?? exifInfo,
|
||||
thumbhash: a.thumbhash,
|
||||
);
|
||||
} else {
|
||||
// add only missing values (and set isLocal to true)
|
||||
return copyWith(
|
||||
localId: localId ?? a.localId,
|
||||
width: width ?? a.width,
|
||||
height: height ?? a.height,
|
||||
exifInfo: exifInfo ?? a.exifInfo?.copyWith(assetId: id), // updated to use assetId
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Asset copyWith({
|
||||
Id? id,
|
||||
String? checksum,
|
||||
String? remoteId,
|
||||
String? localId,
|
||||
int? ownerId,
|
||||
DateTime? fileCreatedAt,
|
||||
DateTime? fileModifiedAt,
|
||||
DateTime? updatedAt,
|
||||
int? durationInSeconds,
|
||||
AssetType? type,
|
||||
short? width,
|
||||
short? height,
|
||||
String? fileName,
|
||||
String? livePhotoVideoId,
|
||||
bool? isFavorite,
|
||||
bool? isArchived,
|
||||
bool? isTrashed,
|
||||
bool? isOffline,
|
||||
ExifInfo? exifInfo,
|
||||
String? stackId,
|
||||
String? stackPrimaryAssetId,
|
||||
int? stackCount,
|
||||
String? thumbhash,
|
||||
AssetVisibilityEnum? visibility,
|
||||
}) => Asset(
|
||||
id: id ?? this.id,
|
||||
checksum: checksum ?? this.checksum,
|
||||
remoteId: remoteId ?? this.remoteId,
|
||||
localId: localId ?? this.localId,
|
||||
ownerId: ownerId ?? this.ownerId,
|
||||
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
|
||||
fileModifiedAt: fileModifiedAt ?? this.fileModifiedAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
durationInSeconds: durationInSeconds ?? this.durationInSeconds,
|
||||
type: type ?? this.type,
|
||||
width: width ?? this.width,
|
||||
height: height ?? this.height,
|
||||
fileName: fileName ?? this.fileName,
|
||||
livePhotoVideoId: livePhotoVideoId ?? this.livePhotoVideoId,
|
||||
isFavorite: isFavorite ?? this.isFavorite,
|
||||
isArchived: isArchived ?? this.isArchived,
|
||||
isTrashed: isTrashed ?? this.isTrashed,
|
||||
isOffline: isOffline ?? this.isOffline,
|
||||
exifInfo: exifInfo ?? this.exifInfo,
|
||||
stackId: stackId ?? this.stackId,
|
||||
stackPrimaryAssetId: stackPrimaryAssetId ?? this.stackPrimaryAssetId,
|
||||
stackCount: stackCount ?? this.stackCount,
|
||||
thumbhash: thumbhash ?? this.thumbhash,
|
||||
visibility: visibility ?? this.visibility,
|
||||
);
|
||||
|
||||
Future<void> put(Isar db) async {
|
||||
await db.assets.put(this);
|
||||
if (exifInfo != null) {
|
||||
await db.exifInfos.put(entity.ExifInfo.fromDto(exifInfo!.copyWith(assetId: id)));
|
||||
}
|
||||
}
|
||||
|
||||
static int compareById(Asset a, Asset b) => a.id.compareTo(b.id);
|
||||
|
||||
static int compareByLocalId(Asset a, Asset b) => compareToNullable(a.localId, b.localId);
|
||||
|
||||
static int compareByChecksum(Asset a, Asset b) => a.checksum.compareTo(b.checksum);
|
||||
|
||||
static int compareByOwnerChecksum(Asset a, Asset b) {
|
||||
final int ownerIdOrder = a.ownerId.compareTo(b.ownerId);
|
||||
if (ownerIdOrder != 0) return ownerIdOrder;
|
||||
return compareByChecksum(a, b);
|
||||
}
|
||||
|
||||
static int compareByOwnerChecksumCreatedModified(Asset a, Asset b) {
|
||||
final int ownerIdOrder = a.ownerId.compareTo(b.ownerId);
|
||||
if (ownerIdOrder != 0) return ownerIdOrder;
|
||||
final int checksumOrder = compareByChecksum(a, b);
|
||||
if (checksumOrder != 0) return checksumOrder;
|
||||
final int createdOrder = a.fileCreatedAt.compareTo(b.fileCreatedAt);
|
||||
if (createdOrder != 0) return createdOrder;
|
||||
return a.fileModifiedAt.compareTo(b.fileModifiedAt);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return """
|
||||
{
|
||||
"id": ${id == Isar.autoIncrement ? '"N/A"' : id},
|
||||
"remoteId": "${remoteId ?? "N/A"}",
|
||||
"localId": "${localId ?? "N/A"}",
|
||||
"checksum": "$checksum",
|
||||
"ownerId": $ownerId,
|
||||
"livePhotoVideoId": "${livePhotoVideoId ?? "N/A"}",
|
||||
"stackId": "${stackId ?? "N/A"}",
|
||||
"stackPrimaryAssetId": "${stackPrimaryAssetId ?? "N/A"}",
|
||||
"stackCount": "$stackCount",
|
||||
"fileCreatedAt": "$fileCreatedAt",
|
||||
"fileModifiedAt": "$fileModifiedAt",
|
||||
"updatedAt": "$updatedAt",
|
||||
"durationInSeconds": $durationInSeconds,
|
||||
"type": "$type",
|
||||
"fileName": "$fileName",
|
||||
"isFavorite": $isFavorite,
|
||||
"isRemote": $isRemote,
|
||||
"storage": "$storage",
|
||||
"width": ${width ?? "N/A"},
|
||||
"height": ${height ?? "N/A"},
|
||||
"isArchived": $isArchived,
|
||||
"isTrashed": $isTrashed,
|
||||
"isOffline": $isOffline,
|
||||
"visibility": "$visibility",
|
||||
}""";
|
||||
}
|
||||
|
||||
static getVisibility(AssetVisibility visibility) => switch (visibility) {
|
||||
AssetVisibility.archive => AssetVisibilityEnum.archive,
|
||||
AssetVisibility.hidden => AssetVisibilityEnum.hidden,
|
||||
AssetVisibility.locked => AssetVisibilityEnum.locked,
|
||||
AssetVisibility.timeline || _ => AssetVisibilityEnum.timeline,
|
||||
};
|
||||
}
|
||||
|
||||
enum AssetType {
|
||||
// do not change this order!
|
||||
other,
|
||||
image,
|
||||
video,
|
||||
audio,
|
||||
}
|
||||
|
||||
extension AssetTypeEnumHelper on AssetTypeEnum {
|
||||
AssetType toAssetType() => switch (this) {
|
||||
AssetTypeEnum.IMAGE => AssetType.image,
|
||||
AssetTypeEnum.VIDEO => AssetType.video,
|
||||
AssetTypeEnum.AUDIO => AssetType.audio,
|
||||
AssetTypeEnum.OTHER => AssetType.other,
|
||||
_ => throw Exception(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Describes where the information of this asset came from:
|
||||
/// only from the local device, only from the remote server or merged from both
|
||||
enum AssetState { local, remote, merged }
|
||||
|
||||
extension AssetsHelper on IsarCollection<Asset> {
|
||||
Future<int> deleteAllByRemoteId(Iterable<String> ids) => ids.isEmpty ? Future.value(0) : remote(ids).deleteAll();
|
||||
Future<int> deleteAllByLocalId(Iterable<String> ids) => ids.isEmpty ? Future.value(0) : local(ids).deleteAll();
|
||||
Future<List<Asset>> getAllByRemoteId(Iterable<String> ids) => ids.isEmpty ? Future.value([]) : remote(ids).findAll();
|
||||
Future<List<Asset>> getAllByLocalId(Iterable<String> ids) => ids.isEmpty ? Future.value([]) : local(ids).findAll();
|
||||
Future<Asset?> getByRemoteId(String id) => where().remoteIdEqualTo(id).findFirst();
|
||||
|
||||
QueryBuilder<Asset, Asset, QAfterWhereClause> remote(Iterable<String> ids) =>
|
||||
where().anyOf(ids, (q, String e) => q.remoteIdEqualTo(e));
|
||||
QueryBuilder<Asset, Asset, QAfterWhereClause> local(Iterable<String> ids) {
|
||||
return where().anyOf(ids, (q, String e) => q.localIdEqualTo(e));
|
||||
}
|
||||
}
|
||||
3711
mobile/lib/entities/asset.entity.g.dart
generated
3711
mobile/lib/entities/asset.entity.g.dart
generated
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'backup_album.entity.g.dart';
|
||||
|
||||
@Collection(inheritance: false)
|
||||
class BackupAlbum {
|
||||
String id;
|
||||
DateTime lastBackup;
|
||||
@Enumerated(EnumType.ordinal)
|
||||
BackupSelection selection;
|
||||
|
||||
BackupAlbum(this.id, this.lastBackup, this.selection);
|
||||
|
||||
Id get isarId => fastHash(id);
|
||||
|
||||
BackupAlbum copyWith({String? id, DateTime? lastBackup, BackupSelection? selection}) {
|
||||
return BackupAlbum(id ?? this.id, lastBackup ?? this.lastBackup, selection ?? this.selection);
|
||||
}
|
||||
}
|
||||
|
||||
enum BackupSelection { none, select, exclude }
|
||||
679
mobile/lib/entities/backup_album.entity.g.dart
generated
679
mobile/lib/entities/backup_album.entity.g.dart
generated
@ -1,679 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'backup_album.entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types
|
||||
|
||||
extension GetBackupAlbumCollection on Isar {
|
||||
IsarCollection<BackupAlbum> get backupAlbums => this.collection();
|
||||
}
|
||||
|
||||
const BackupAlbumSchema = CollectionSchema(
|
||||
name: r'BackupAlbum',
|
||||
id: 8308487201128361847,
|
||||
properties: {
|
||||
r'id': PropertySchema(id: 0, name: r'id', type: IsarType.string),
|
||||
r'lastBackup': PropertySchema(
|
||||
id: 1,
|
||||
name: r'lastBackup',
|
||||
type: IsarType.dateTime,
|
||||
),
|
||||
r'selection': PropertySchema(
|
||||
id: 2,
|
||||
name: r'selection',
|
||||
type: IsarType.byte,
|
||||
enumMap: _BackupAlbumselectionEnumValueMap,
|
||||
),
|
||||
},
|
||||
|
||||
estimateSize: _backupAlbumEstimateSize,
|
||||
serialize: _backupAlbumSerialize,
|
||||
deserialize: _backupAlbumDeserialize,
|
||||
deserializeProp: _backupAlbumDeserializeProp,
|
||||
idName: r'isarId',
|
||||
indexes: {},
|
||||
links: {},
|
||||
embeddedSchemas: {},
|
||||
|
||||
getId: _backupAlbumGetId,
|
||||
getLinks: _backupAlbumGetLinks,
|
||||
attach: _backupAlbumAttach,
|
||||
version: '3.3.0-dev.3',
|
||||
);
|
||||
|
||||
int _backupAlbumEstimateSize(
|
||||
BackupAlbum object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.id.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _backupAlbumSerialize(
|
||||
BackupAlbum object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeString(offsets[0], object.id);
|
||||
writer.writeDateTime(offsets[1], object.lastBackup);
|
||||
writer.writeByte(offsets[2], object.selection.index);
|
||||
}
|
||||
|
||||
BackupAlbum _backupAlbumDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = BackupAlbum(
|
||||
reader.readString(offsets[0]),
|
||||
reader.readDateTime(offsets[1]),
|
||||
_BackupAlbumselectionValueEnumMap[reader.readByteOrNull(offsets[2])] ??
|
||||
BackupSelection.none,
|
||||
);
|
||||
return object;
|
||||
}
|
||||
|
||||
P _backupAlbumDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 1:
|
||||
return (reader.readDateTime(offset)) as P;
|
||||
case 2:
|
||||
return (_BackupAlbumselectionValueEnumMap[reader.readByteOrNull(
|
||||
offset,
|
||||
)] ??
|
||||
BackupSelection.none)
|
||||
as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
const _BackupAlbumselectionEnumValueMap = {
|
||||
'none': 0,
|
||||
'select': 1,
|
||||
'exclude': 2,
|
||||
};
|
||||
const _BackupAlbumselectionValueEnumMap = {
|
||||
0: BackupSelection.none,
|
||||
1: BackupSelection.select,
|
||||
2: BackupSelection.exclude,
|
||||
};
|
||||
|
||||
Id _backupAlbumGetId(BackupAlbum object) {
|
||||
return object.isarId;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _backupAlbumGetLinks(BackupAlbum object) {
|
||||
return [];
|
||||
}
|
||||
|
||||
void _backupAlbumAttach(
|
||||
IsarCollection<dynamic> col,
|
||||
Id id,
|
||||
BackupAlbum object,
|
||||
) {}
|
||||
|
||||
extension BackupAlbumQueryWhereSort
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QWhere> {
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterWhere> anyIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension BackupAlbumQueryWhere
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QWhereClause> {
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterWhereClause> isarIdEqualTo(
|
||||
Id isarId,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(lower: isarId, upper: isarId),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterWhereClause> isarIdNotEqualTo(
|
||||
Id isarId,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterWhereClause> isarIdGreaterThan(
|
||||
Id isarId, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterWhereClause> isarIdLessThan(
|
||||
Id isarId, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterWhereClause> isarIdBetween(
|
||||
Id lowerIsarId,
|
||||
Id upperIsarId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(
|
||||
lower: lowerIsarId,
|
||||
includeLower: includeLower,
|
||||
upper: upperIsarId,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension BackupAlbumQueryFilter
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QFilterCondition> {
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idLessThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.startsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.endsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idContains(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.contains(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idMatches(
|
||||
String pattern, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.matches(
|
||||
property: r'id',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> idIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> isarIdEqualTo(
|
||||
Id value,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'isarId', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
isarIdGreaterThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> isarIdLessThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition> isarIdBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'isarId',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
lastBackupEqualTo(DateTime value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'lastBackup', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
lastBackupGreaterThan(DateTime value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'lastBackup',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
lastBackupLessThan(DateTime value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'lastBackup',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
lastBackupBetween(
|
||||
DateTime lower,
|
||||
DateTime upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'lastBackup',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
selectionEqualTo(BackupSelection value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'selection', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
selectionGreaterThan(BackupSelection value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'selection',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
selectionLessThan(BackupSelection value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'selection',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterFilterCondition>
|
||||
selectionBetween(
|
||||
BackupSelection lower,
|
||||
BackupSelection upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'selection',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension BackupAlbumQueryObject
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QFilterCondition> {}
|
||||
|
||||
extension BackupAlbumQueryLinks
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QFilterCondition> {}
|
||||
|
||||
extension BackupAlbumQuerySortBy
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QSortBy> {
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> sortById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> sortByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> sortByLastBackup() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'lastBackup', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> sortByLastBackupDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'lastBackup', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> sortBySelection() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'selection', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> sortBySelectionDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'selection', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension BackupAlbumQuerySortThenBy
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QSortThenBy> {
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenByIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenByIsarIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenByLastBackup() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'lastBackup', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenByLastBackupDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'lastBackup', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenBySelection() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'selection', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QAfterSortBy> thenBySelectionDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'selection', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension BackupAlbumQueryWhereDistinct
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QDistinct> {
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QDistinct> distinctById({
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'id', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QDistinct> distinctByLastBackup() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'lastBackup');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupAlbum, QDistinct> distinctBySelection() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'selection');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension BackupAlbumQueryProperty
|
||||
on QueryBuilder<BackupAlbum, BackupAlbum, QQueryProperty> {
|
||||
QueryBuilder<BackupAlbum, int, QQueryOperations> isarIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'isarId');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, String, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, DateTime, QQueryOperations> lastBackupProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'lastBackup');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<BackupAlbum, BackupSelection, QQueryOperations>
|
||||
selectionProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'selection');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
class DeviceAsset {
|
||||
DeviceAsset({required this.hash});
|
||||
|
||||
@Index(unique: false, type: IndexType.hash)
|
||||
List<byte> hash;
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'duplicated_asset.entity.g.dart';
|
||||
|
||||
@Collection(inheritance: false)
|
||||
class DuplicatedAsset {
|
||||
String id;
|
||||
DuplicatedAsset(this.id);
|
||||
Id get isarId => fastHash(id);
|
||||
}
|
||||
444
mobile/lib/entities/duplicated_asset.entity.g.dart
generated
444
mobile/lib/entities/duplicated_asset.entity.g.dart
generated
@ -1,444 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'duplicated_asset.entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types
|
||||
|
||||
extension GetDuplicatedAssetCollection on Isar {
|
||||
IsarCollection<DuplicatedAsset> get duplicatedAssets => this.collection();
|
||||
}
|
||||
|
||||
const DuplicatedAssetSchema = CollectionSchema(
|
||||
name: r'DuplicatedAsset',
|
||||
id: -2679334728174694496,
|
||||
properties: {
|
||||
r'id': PropertySchema(id: 0, name: r'id', type: IsarType.string),
|
||||
},
|
||||
|
||||
estimateSize: _duplicatedAssetEstimateSize,
|
||||
serialize: _duplicatedAssetSerialize,
|
||||
deserialize: _duplicatedAssetDeserialize,
|
||||
deserializeProp: _duplicatedAssetDeserializeProp,
|
||||
idName: r'isarId',
|
||||
indexes: {},
|
||||
links: {},
|
||||
embeddedSchemas: {},
|
||||
|
||||
getId: _duplicatedAssetGetId,
|
||||
getLinks: _duplicatedAssetGetLinks,
|
||||
attach: _duplicatedAssetAttach,
|
||||
version: '3.3.0-dev.3',
|
||||
);
|
||||
|
||||
int _duplicatedAssetEstimateSize(
|
||||
DuplicatedAsset object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.id.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _duplicatedAssetSerialize(
|
||||
DuplicatedAsset object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeString(offsets[0], object.id);
|
||||
}
|
||||
|
||||
DuplicatedAsset _duplicatedAssetDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = DuplicatedAsset(reader.readString(offsets[0]));
|
||||
return object;
|
||||
}
|
||||
|
||||
P _duplicatedAssetDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _duplicatedAssetGetId(DuplicatedAsset object) {
|
||||
return object.isarId;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _duplicatedAssetGetLinks(DuplicatedAsset object) {
|
||||
return [];
|
||||
}
|
||||
|
||||
void _duplicatedAssetAttach(
|
||||
IsarCollection<dynamic> col,
|
||||
Id id,
|
||||
DuplicatedAsset object,
|
||||
) {}
|
||||
|
||||
extension DuplicatedAssetQueryWhereSort
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QWhere> {
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterWhere> anyIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DuplicatedAssetQueryWhere
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QWhereClause> {
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterWhereClause>
|
||||
isarIdEqualTo(Id isarId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(lower: isarId, upper: isarId),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterWhereClause>
|
||||
isarIdNotEqualTo(Id isarId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterWhereClause>
|
||||
isarIdGreaterThan(Id isarId, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterWhereClause>
|
||||
isarIdLessThan(Id isarId, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterWhereClause>
|
||||
isarIdBetween(
|
||||
Id lowerIsarId,
|
||||
Id upperIsarId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(
|
||||
lower: lowerIsarId,
|
||||
includeLower: includeLower,
|
||||
upper: upperIsarId,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DuplicatedAssetQueryFilter
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QFilterCondition> {
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idEqualTo(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idLessThan(String value, {bool include = false, bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idStartsWith(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.startsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idEndsWith(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.endsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idContains(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.contains(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idMatches(String pattern, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.matches(
|
||||
property: r'id',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
idIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
isarIdEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'isarId', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
isarIdGreaterThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
isarIdLessThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterFilterCondition>
|
||||
isarIdBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'isarId',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DuplicatedAssetQueryObject
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QFilterCondition> {}
|
||||
|
||||
extension DuplicatedAssetQueryLinks
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QFilterCondition> {}
|
||||
|
||||
extension DuplicatedAssetQuerySortBy
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QSortBy> {
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterSortBy> sortById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterSortBy> sortByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DuplicatedAssetQuerySortThenBy
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QSortThenBy> {
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterSortBy> thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterSortBy> thenByIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QAfterSortBy>
|
||||
thenByIsarIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DuplicatedAssetQueryWhereDistinct
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QDistinct> {
|
||||
QueryBuilder<DuplicatedAsset, DuplicatedAsset, QDistinct> distinctById({
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'id', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DuplicatedAssetQueryProperty
|
||||
on QueryBuilder<DuplicatedAsset, DuplicatedAsset, QQueryProperty> {
|
||||
QueryBuilder<DuplicatedAsset, int, QQueryOperations> isarIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'isarId');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DuplicatedAsset, String, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'etag.entity.g.dart';
|
||||
|
||||
@Collection(inheritance: false)
|
||||
class ETag {
|
||||
ETag({required this.id, this.assetCount, this.time});
|
||||
Id get isarId => fastHash(id);
|
||||
@Index(unique: true, replace: true, type: IndexType.hash)
|
||||
String id;
|
||||
int? assetCount;
|
||||
DateTime? time;
|
||||
}
|
||||
796
mobile/lib/entities/etag.entity.g.dart
generated
796
mobile/lib/entities/etag.entity.g.dart
generated
@ -1,796 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'etag.entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types
|
||||
|
||||
extension GetETagCollection on Isar {
|
||||
IsarCollection<ETag> get eTags => this.collection();
|
||||
}
|
||||
|
||||
const ETagSchema = CollectionSchema(
|
||||
name: r'ETag',
|
||||
id: -644290296585643859,
|
||||
properties: {
|
||||
r'assetCount': PropertySchema(
|
||||
id: 0,
|
||||
name: r'assetCount',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'id': PropertySchema(id: 1, name: r'id', type: IsarType.string),
|
||||
r'time': PropertySchema(id: 2, name: r'time', type: IsarType.dateTime),
|
||||
},
|
||||
|
||||
estimateSize: _eTagEstimateSize,
|
||||
serialize: _eTagSerialize,
|
||||
deserialize: _eTagDeserialize,
|
||||
deserializeProp: _eTagDeserializeProp,
|
||||
idName: r'isarId',
|
||||
indexes: {
|
||||
r'id': IndexSchema(
|
||||
id: -3268401673993471357,
|
||||
name: r'id',
|
||||
unique: true,
|
||||
replace: true,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'id',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
},
|
||||
links: {},
|
||||
embeddedSchemas: {},
|
||||
|
||||
getId: _eTagGetId,
|
||||
getLinks: _eTagGetLinks,
|
||||
attach: _eTagAttach,
|
||||
version: '3.3.0-dev.3',
|
||||
);
|
||||
|
||||
int _eTagEstimateSize(
|
||||
ETag object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.id.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _eTagSerialize(
|
||||
ETag object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeLong(offsets[0], object.assetCount);
|
||||
writer.writeString(offsets[1], object.id);
|
||||
writer.writeDateTime(offsets[2], object.time);
|
||||
}
|
||||
|
||||
ETag _eTagDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = ETag(
|
||||
assetCount: reader.readLongOrNull(offsets[0]),
|
||||
id: reader.readString(offsets[1]),
|
||||
time: reader.readDateTimeOrNull(offsets[2]),
|
||||
);
|
||||
return object;
|
||||
}
|
||||
|
||||
P _eTagDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readLongOrNull(offset)) as P;
|
||||
case 1:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 2:
|
||||
return (reader.readDateTimeOrNull(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _eTagGetId(ETag object) {
|
||||
return object.isarId;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _eTagGetLinks(ETag object) {
|
||||
return [];
|
||||
}
|
||||
|
||||
void _eTagAttach(IsarCollection<dynamic> col, Id id, ETag object) {}
|
||||
|
||||
extension ETagByIndex on IsarCollection<ETag> {
|
||||
Future<ETag?> getById(String id) {
|
||||
return getByIndex(r'id', [id]);
|
||||
}
|
||||
|
||||
ETag? getByIdSync(String id) {
|
||||
return getByIndexSync(r'id', [id]);
|
||||
}
|
||||
|
||||
Future<bool> deleteById(String id) {
|
||||
return deleteByIndex(r'id', [id]);
|
||||
}
|
||||
|
||||
bool deleteByIdSync(String id) {
|
||||
return deleteByIndexSync(r'id', [id]);
|
||||
}
|
||||
|
||||
Future<List<ETag?>> getAllById(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return getAllByIndex(r'id', values);
|
||||
}
|
||||
|
||||
List<ETag?> getAllByIdSync(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return getAllByIndexSync(r'id', values);
|
||||
}
|
||||
|
||||
Future<int> deleteAllById(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return deleteAllByIndex(r'id', values);
|
||||
}
|
||||
|
||||
int deleteAllByIdSync(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return deleteAllByIndexSync(r'id', values);
|
||||
}
|
||||
|
||||
Future<Id> putById(ETag object) {
|
||||
return putByIndex(r'id', object);
|
||||
}
|
||||
|
||||
Id putByIdSync(ETag object, {bool saveLinks = true}) {
|
||||
return putByIndexSync(r'id', object, saveLinks: saveLinks);
|
||||
}
|
||||
|
||||
Future<List<Id>> putAllById(List<ETag> objects) {
|
||||
return putAllByIndex(r'id', objects);
|
||||
}
|
||||
|
||||
List<Id> putAllByIdSync(List<ETag> objects, {bool saveLinks = true}) {
|
||||
return putAllByIndexSync(r'id', objects, saveLinks: saveLinks);
|
||||
}
|
||||
}
|
||||
|
||||
extension ETagQueryWhereSort on QueryBuilder<ETag, ETag, QWhere> {
|
||||
QueryBuilder<ETag, ETag, QAfterWhere> anyIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension ETagQueryWhere on QueryBuilder<ETag, ETag, QWhereClause> {
|
||||
QueryBuilder<ETag, ETag, QAfterWhereClause> isarIdEqualTo(Id isarId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(lower: isarId, upper: isarId),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterWhereClause> isarIdNotEqualTo(Id isarId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterWhereClause> isarIdGreaterThan(
|
||||
Id isarId, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterWhereClause> isarIdLessThan(
|
||||
Id isarId, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterWhereClause> isarIdBetween(
|
||||
Id lowerIsarId,
|
||||
Id upperIsarId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(
|
||||
lower: lowerIsarId,
|
||||
includeLower: includeLower,
|
||||
upper: upperIsarId,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterWhereClause> idEqualTo(String id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IndexWhereClause.equalTo(indexName: r'id', value: [id]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterWhereClause> idNotEqualTo(String id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [],
|
||||
upper: [id],
|
||||
includeUpper: false,
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [id],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [id],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [],
|
||||
upper: [id],
|
||||
includeUpper: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension ETagQueryFilter on QueryBuilder<ETag, ETag, QFilterCondition> {
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> assetCountIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNull(property: r'assetCount'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> assetCountIsNotNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNotNull(property: r'assetCount'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> assetCountEqualTo(
|
||||
int? value,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'assetCount', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> assetCountGreaterThan(
|
||||
int? value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'assetCount',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> assetCountLessThan(
|
||||
int? value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'assetCount',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> assetCountBetween(
|
||||
int? lower,
|
||||
int? upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'assetCount',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idLessThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.startsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.endsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idContains(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.contains(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idMatches(
|
||||
String pattern, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.matches(
|
||||
property: r'id',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> idIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> isarIdEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'isarId', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> isarIdGreaterThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> isarIdLessThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> isarIdBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'isarId',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> timeIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNull(property: r'time'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> timeIsNotNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNotNull(property: r'time'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> timeEqualTo(DateTime? value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'time', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> timeGreaterThan(
|
||||
DateTime? value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> timeLessThan(
|
||||
DateTime? value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'time',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterFilterCondition> timeBetween(
|
||||
DateTime? lower,
|
||||
DateTime? upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'time',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension ETagQueryObject on QueryBuilder<ETag, ETag, QFilterCondition> {}
|
||||
|
||||
extension ETagQueryLinks on QueryBuilder<ETag, ETag, QFilterCondition> {}
|
||||
|
||||
extension ETagQuerySortBy on QueryBuilder<ETag, ETag, QSortBy> {
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> sortByAssetCount() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetCount', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> sortByAssetCountDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetCount', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> sortById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> sortByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> sortByTime() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'time', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> sortByTimeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'time', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension ETagQuerySortThenBy on QueryBuilder<ETag, ETag, QSortThenBy> {
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenByAssetCount() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetCount', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenByAssetCountDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetCount', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenByIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenByIsarIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenByTime() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'time', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QAfterSortBy> thenByTimeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'time', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension ETagQueryWhereDistinct on QueryBuilder<ETag, ETag, QDistinct> {
|
||||
QueryBuilder<ETag, ETag, QDistinct> distinctByAssetCount() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'assetCount');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QDistinct> distinctById({
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'id', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, ETag, QDistinct> distinctByTime() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'time');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension ETagQueryProperty on QueryBuilder<ETag, ETag, QQueryProperty> {
|
||||
QueryBuilder<ETag, int, QQueryOperations> isarIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'isarId');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, int?, QQueryOperations> assetCountProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'assetCount');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, String, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<ETag, DateTime?, QQueryOperations> timeProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'time');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
import 'package:immich_mobile/entities/device_asset.entity.dart';
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'ios_device_asset.entity.g.dart';
|
||||
|
||||
@Collection()
|
||||
class IOSDeviceAsset extends DeviceAsset {
|
||||
IOSDeviceAsset({required this.id, required super.hash});
|
||||
|
||||
@Index(replace: true, unique: true, type: IndexType.hash)
|
||||
String id;
|
||||
Id get isarId => fastHash(id);
|
||||
}
|
||||
766
mobile/lib/entities/ios_device_asset.entity.g.dart
generated
766
mobile/lib/entities/ios_device_asset.entity.g.dart
generated
@ -1,766 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'ios_device_asset.entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types
|
||||
|
||||
extension GetIOSDeviceAssetCollection on Isar {
|
||||
IsarCollection<IOSDeviceAsset> get iOSDeviceAssets => this.collection();
|
||||
}
|
||||
|
||||
const IOSDeviceAssetSchema = CollectionSchema(
|
||||
name: r'IOSDeviceAsset',
|
||||
id: -1671546753821948030,
|
||||
properties: {
|
||||
r'hash': PropertySchema(id: 0, name: r'hash', type: IsarType.byteList),
|
||||
r'id': PropertySchema(id: 1, name: r'id', type: IsarType.string),
|
||||
},
|
||||
|
||||
estimateSize: _iOSDeviceAssetEstimateSize,
|
||||
serialize: _iOSDeviceAssetSerialize,
|
||||
deserialize: _iOSDeviceAssetDeserialize,
|
||||
deserializeProp: _iOSDeviceAssetDeserializeProp,
|
||||
idName: r'isarId',
|
||||
indexes: {
|
||||
r'id': IndexSchema(
|
||||
id: -3268401673993471357,
|
||||
name: r'id',
|
||||
unique: true,
|
||||
replace: true,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'id',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
r'hash': IndexSchema(
|
||||
id: -7973251393006690288,
|
||||
name: r'hash',
|
||||
unique: false,
|
||||
replace: false,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'hash',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
},
|
||||
links: {},
|
||||
embeddedSchemas: {},
|
||||
|
||||
getId: _iOSDeviceAssetGetId,
|
||||
getLinks: _iOSDeviceAssetGetLinks,
|
||||
attach: _iOSDeviceAssetAttach,
|
||||
version: '3.3.0-dev.3',
|
||||
);
|
||||
|
||||
int _iOSDeviceAssetEstimateSize(
|
||||
IOSDeviceAsset object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.hash.length;
|
||||
bytesCount += 3 + object.id.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _iOSDeviceAssetSerialize(
|
||||
IOSDeviceAsset object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeByteList(offsets[0], object.hash);
|
||||
writer.writeString(offsets[1], object.id);
|
||||
}
|
||||
|
||||
IOSDeviceAsset _iOSDeviceAssetDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = IOSDeviceAsset(
|
||||
hash: reader.readByteList(offsets[0]) ?? [],
|
||||
id: reader.readString(offsets[1]),
|
||||
);
|
||||
return object;
|
||||
}
|
||||
|
||||
P _iOSDeviceAssetDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readByteList(offset) ?? []) as P;
|
||||
case 1:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _iOSDeviceAssetGetId(IOSDeviceAsset object) {
|
||||
return object.isarId;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _iOSDeviceAssetGetLinks(IOSDeviceAsset object) {
|
||||
return [];
|
||||
}
|
||||
|
||||
void _iOSDeviceAssetAttach(
|
||||
IsarCollection<dynamic> col,
|
||||
Id id,
|
||||
IOSDeviceAsset object,
|
||||
) {}
|
||||
|
||||
extension IOSDeviceAssetByIndex on IsarCollection<IOSDeviceAsset> {
|
||||
Future<IOSDeviceAsset?> getById(String id) {
|
||||
return getByIndex(r'id', [id]);
|
||||
}
|
||||
|
||||
IOSDeviceAsset? getByIdSync(String id) {
|
||||
return getByIndexSync(r'id', [id]);
|
||||
}
|
||||
|
||||
Future<bool> deleteById(String id) {
|
||||
return deleteByIndex(r'id', [id]);
|
||||
}
|
||||
|
||||
bool deleteByIdSync(String id) {
|
||||
return deleteByIndexSync(r'id', [id]);
|
||||
}
|
||||
|
||||
Future<List<IOSDeviceAsset?>> getAllById(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return getAllByIndex(r'id', values);
|
||||
}
|
||||
|
||||
List<IOSDeviceAsset?> getAllByIdSync(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return getAllByIndexSync(r'id', values);
|
||||
}
|
||||
|
||||
Future<int> deleteAllById(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return deleteAllByIndex(r'id', values);
|
||||
}
|
||||
|
||||
int deleteAllByIdSync(List<String> idValues) {
|
||||
final values = idValues.map((e) => [e]).toList();
|
||||
return deleteAllByIndexSync(r'id', values);
|
||||
}
|
||||
|
||||
Future<Id> putById(IOSDeviceAsset object) {
|
||||
return putByIndex(r'id', object);
|
||||
}
|
||||
|
||||
Id putByIdSync(IOSDeviceAsset object, {bool saveLinks = true}) {
|
||||
return putByIndexSync(r'id', object, saveLinks: saveLinks);
|
||||
}
|
||||
|
||||
Future<List<Id>> putAllById(List<IOSDeviceAsset> objects) {
|
||||
return putAllByIndex(r'id', objects);
|
||||
}
|
||||
|
||||
List<Id> putAllByIdSync(
|
||||
List<IOSDeviceAsset> objects, {
|
||||
bool saveLinks = true,
|
||||
}) {
|
||||
return putAllByIndexSync(r'id', objects, saveLinks: saveLinks);
|
||||
}
|
||||
}
|
||||
|
||||
extension IOSDeviceAssetQueryWhereSort
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QWhere> {
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhere> anyIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension IOSDeviceAssetQueryWhere
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QWhereClause> {
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause> isarIdEqualTo(
|
||||
Id isarId,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(lower: isarId, upper: isarId),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause>
|
||||
isarIdNotEqualTo(Id isarId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause>
|
||||
isarIdGreaterThan(Id isarId, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: isarId, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause>
|
||||
isarIdLessThan(Id isarId, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: isarId, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause> isarIdBetween(
|
||||
Id lowerIsarId,
|
||||
Id upperIsarId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(
|
||||
lower: lowerIsarId,
|
||||
includeLower: includeLower,
|
||||
upper: upperIsarId,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause> idEqualTo(
|
||||
String id,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IndexWhereClause.equalTo(indexName: r'id', value: [id]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause> idNotEqualTo(
|
||||
String id,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [],
|
||||
upper: [id],
|
||||
includeUpper: false,
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [id],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [id],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'id',
|
||||
lower: [],
|
||||
upper: [id],
|
||||
includeUpper: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause> hashEqualTo(
|
||||
List<int> hash,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IndexWhereClause.equalTo(indexName: r'hash', value: [hash]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterWhereClause>
|
||||
hashNotEqualTo(List<int> hash) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [],
|
||||
upper: [hash],
|
||||
includeUpper: false,
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [hash],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [hash],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [],
|
||||
upper: [hash],
|
||||
includeUpper: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension IOSDeviceAssetQueryFilter
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QFilterCondition> {
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashElementEqualTo(int value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'hash', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashElementGreaterThan(int value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'hash',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashElementLessThan(int value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'hash',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashElementBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'hash',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthEqualTo(int length) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', length, true, length, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, false, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthLessThan(int length, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, true, length, include);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthGreaterThan(int length, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', length, include, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
hashLengthBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'hash',
|
||||
lower,
|
||||
includeLower,
|
||||
upper,
|
||||
includeUpper,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition> idEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
idGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
idLessThan(String value, {bool include = false, bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition> idBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
idStartsWith(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.startsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
idEndsWith(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.endsWith(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
idContains(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.contains(
|
||||
property: r'id',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition> idMatches(
|
||||
String pattern, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.matches(
|
||||
property: r'id',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
idIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
idIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(property: r'id', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
isarIdEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'isarId', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
isarIdGreaterThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
isarIdLessThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'isarId',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterFilterCondition>
|
||||
isarIdBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'isarId',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension IOSDeviceAssetQueryObject
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QFilterCondition> {}
|
||||
|
||||
extension IOSDeviceAssetQueryLinks
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QFilterCondition> {}
|
||||
|
||||
extension IOSDeviceAssetQuerySortBy
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QSortBy> {
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterSortBy> sortById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterSortBy> sortByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension IOSDeviceAssetQuerySortThenBy
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QSortThenBy> {
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterSortBy> thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterSortBy> thenByIsarId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QAfterSortBy>
|
||||
thenByIsarIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isarId', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension IOSDeviceAssetQueryWhereDistinct
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QDistinct> {
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QDistinct> distinctByHash() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'hash');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QDistinct> distinctById({
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'id', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension IOSDeviceAssetQueryProperty
|
||||
on QueryBuilder<IOSDeviceAsset, IOSDeviceAsset, QQueryProperty> {
|
||||
QueryBuilder<IOSDeviceAsset, int, QQueryOperations> isarIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'isarId');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, List<int>, QQueryOperations> hashProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'hash');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<IOSDeviceAsset, String, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,38 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||
import 'package:immich_mobile/domain/services/store.service.dart';
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
final Store = StoreService.I;
|
||||
|
||||
class SSLClientCertStoreVal {
|
||||
final Uint8List data;
|
||||
final String? password;
|
||||
|
||||
const SSLClientCertStoreVal(this.data, this.password);
|
||||
|
||||
Future<void> save() async {
|
||||
final b64Str = base64Encode(data);
|
||||
await Store.put(StoreKey.sslClientCertData, b64Str);
|
||||
if (password != null) {
|
||||
await Store.put(StoreKey.sslClientPasswd, password!);
|
||||
}
|
||||
}
|
||||
|
||||
static SSLClientCertStoreVal? load() {
|
||||
final b64Str = Store.tryGet<String>(StoreKey.sslClientCertData);
|
||||
if (b64Str == null) {
|
||||
return null;
|
||||
}
|
||||
final Uint8List certData = base64Decode(b64Str);
|
||||
final passwd = Store.tryGet<String>(StoreKey.sslClientPasswd);
|
||||
return SSLClientCertStoreVal(certData, passwd);
|
||||
}
|
||||
|
||||
static Future<void> delete() async {
|
||||
await Store.delete(StoreKey.sslClientCertData);
|
||||
await Store.delete(StoreKey.sslClientPasswd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,26 +1,9 @@
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||
import 'package:immich_mobile/entities/asset.entity.dart' as isar hide AssetTypeEnumHelper;
|
||||
import 'package:immich_mobile/extensions/string_extensions.dart';
|
||||
import 'package:immich_mobile/infrastructure/utils/exif.converter.dart';
|
||||
import 'package:immich_mobile/utils/timezone.dart';
|
||||
import 'package:openapi/api.dart' as api;
|
||||
|
||||
extension TZExtension on isar.Asset {
|
||||
/// Returns the created time of the asset from the exif info (if available) or from
|
||||
/// the fileCreatedAt field, adjusted to the timezone value from the exif info along with
|
||||
/// the timezone offset in [Duration]
|
||||
(DateTime, Duration) getTZAdjustedTimeAndOffset() {
|
||||
DateTime dt = fileCreatedAt.toLocal();
|
||||
|
||||
if (exifInfo?.dateTimeOriginal != null) {
|
||||
return applyTimezoneOffset(dateTime: exifInfo!.dateTimeOriginal!, timeZone: exifInfo?.timeZone);
|
||||
}
|
||||
|
||||
return (dt, dt.timeZoneOffset);
|
||||
}
|
||||
}
|
||||
|
||||
extension DTOToAsset on api.AssetResponseDto {
|
||||
RemoteAsset toDto() {
|
||||
return RemoteAsset(
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
|
||||
extension ListExtension<E> on List<E> {
|
||||
List<E> uniqueConsecutive({int Function(E a, E b)? compare, void Function(E a, E b)? onDuplicate}) {
|
||||
@ -40,31 +37,6 @@ extension IntListExtension on Iterable<int> {
|
||||
}
|
||||
}
|
||||
|
||||
extension AssetListExtension on Iterable<Asset> {
|
||||
/// Returns the assets that are already available in the Immich server
|
||||
Iterable<Asset> remoteOnly({void Function()? errorCallback}) {
|
||||
final bool onlyRemote = every((e) => e.isRemote);
|
||||
if (!onlyRemote) {
|
||||
if (errorCallback != null) errorCallback();
|
||||
return where((a) => a.isRemote);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/// Returns the assets that are owned by the user passed to the [owner] param
|
||||
/// If [owner] is null, an empty list is returned
|
||||
Iterable<Asset> ownedOnly(UserDto? owner, {void Function()? errorCallback}) {
|
||||
if (owner == null) return [];
|
||||
final isarUserId = fastHash(owner.id);
|
||||
final bool onlyOwned = every((e) => e.ownerId == isarUserId);
|
||||
if (!onlyOwned) {
|
||||
if (errorCallback != null) errorCallback();
|
||||
return where((a) => a.ownerId == isarUserId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
extension SortedByProperty<T> on Iterable<T> {
|
||||
Iterable<T> sortedByField(Comparable Function(T e) key) {
|
||||
return sorted((a, b) => key(a).compareTo(key(b)));
|
||||
|
||||
3
mobile/lib/extensions/object_extensions.dart
Normal file
3
mobile/lib/extensions/object_extensions.dart
Normal file
@ -0,0 +1,3 @@
|
||||
extension Let<T extends Object> on T {
|
||||
R let<R>(R Function(T) transform) => transform(this);
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:intl/message_format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/utils/debug_print.dart';
|
||||
import 'package:intl/message_format.dart';
|
||||
|
||||
extension StringTranslateExtension on String {
|
||||
String t({BuildContext? context, Map<String, Object>? args}) {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:immich_mobile/domain/models/asset_edit.model.dart';
|
||||
import 'package:immich_mobile/extensions/object_extensions.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/asset_edit.entity.drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||
import 'package:openapi/api.dart' hide AssetEditAction;
|
||||
|
||||
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_asset_edit_asset_id ON asset_edit_entity (asset_id)')
|
||||
class AssetEditEntity extends Table with DriftDefaultsMixin {
|
||||
@ -27,7 +29,12 @@ final JsonTypeConverter2<Map<String, Object?>, Uint8List, Object?> editParameter
|
||||
);
|
||||
|
||||
extension AssetEditEntityDataDomainEx on AssetEditEntityData {
|
||||
AssetEdit toDto() {
|
||||
return AssetEdit(action: action, parameters: parameters);
|
||||
AssetEdit? toDto() {
|
||||
return switch (action) {
|
||||
AssetEditAction.crop => CropParameters.fromJson(parameters)?.let(CropEdit.new),
|
||||
AssetEditAction.rotate => RotateParameters.fromJson(parameters)?.let(RotateEdit.new),
|
||||
AssetEditAction.mirror => MirrorParameters.fromJson(parameters)?.let(MirrorEdit.new),
|
||||
AssetEditAction.other => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:immich_mobile/domain/models/device_asset.model.dart';
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'device_asset.entity.g.dart';
|
||||
|
||||
@Collection(inheritance: false)
|
||||
class DeviceAssetEntity {
|
||||
Id get id => fastHash(assetId);
|
||||
|
||||
@Index(replace: true, unique: true, type: IndexType.hash)
|
||||
final String assetId;
|
||||
@Index(unique: false, type: IndexType.hash)
|
||||
final List<byte> hash;
|
||||
final DateTime modifiedTime;
|
||||
|
||||
const DeviceAssetEntity({required this.assetId, required this.hash, required this.modifiedTime});
|
||||
|
||||
DeviceAsset toModel() => DeviceAsset(assetId: assetId, hash: Uint8List.fromList(hash), modifiedTime: modifiedTime);
|
||||
|
||||
static DeviceAssetEntity fromDto(DeviceAsset dto) =>
|
||||
DeviceAssetEntity(assetId: dto.assetId, hash: dto.hash, modifiedTime: dto.modifiedTime);
|
||||
}
|
||||
@ -1,874 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'device_asset.entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types
|
||||
|
||||
extension GetDeviceAssetEntityCollection on Isar {
|
||||
IsarCollection<DeviceAssetEntity> get deviceAssetEntitys => this.collection();
|
||||
}
|
||||
|
||||
const DeviceAssetEntitySchema = CollectionSchema(
|
||||
name: r'DeviceAssetEntity',
|
||||
id: 6967030785073446271,
|
||||
properties: {
|
||||
r'assetId': PropertySchema(id: 0, name: r'assetId', type: IsarType.string),
|
||||
r'hash': PropertySchema(id: 1, name: r'hash', type: IsarType.byteList),
|
||||
r'modifiedTime': PropertySchema(
|
||||
id: 2,
|
||||
name: r'modifiedTime',
|
||||
type: IsarType.dateTime,
|
||||
),
|
||||
},
|
||||
|
||||
estimateSize: _deviceAssetEntityEstimateSize,
|
||||
serialize: _deviceAssetEntitySerialize,
|
||||
deserialize: _deviceAssetEntityDeserialize,
|
||||
deserializeProp: _deviceAssetEntityDeserializeProp,
|
||||
idName: r'id',
|
||||
indexes: {
|
||||
r'assetId': IndexSchema(
|
||||
id: 174362542210192109,
|
||||
name: r'assetId',
|
||||
unique: true,
|
||||
replace: true,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'assetId',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
r'hash': IndexSchema(
|
||||
id: -7973251393006690288,
|
||||
name: r'hash',
|
||||
unique: false,
|
||||
replace: false,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'hash',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
},
|
||||
links: {},
|
||||
embeddedSchemas: {},
|
||||
|
||||
getId: _deviceAssetEntityGetId,
|
||||
getLinks: _deviceAssetEntityGetLinks,
|
||||
attach: _deviceAssetEntityAttach,
|
||||
version: '3.3.0-dev.3',
|
||||
);
|
||||
|
||||
int _deviceAssetEntityEstimateSize(
|
||||
DeviceAssetEntity object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.assetId.length * 3;
|
||||
bytesCount += 3 + object.hash.length;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _deviceAssetEntitySerialize(
|
||||
DeviceAssetEntity object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeString(offsets[0], object.assetId);
|
||||
writer.writeByteList(offsets[1], object.hash);
|
||||
writer.writeDateTime(offsets[2], object.modifiedTime);
|
||||
}
|
||||
|
||||
DeviceAssetEntity _deviceAssetEntityDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = DeviceAssetEntity(
|
||||
assetId: reader.readString(offsets[0]),
|
||||
hash: reader.readByteList(offsets[1]) ?? [],
|
||||
modifiedTime: reader.readDateTime(offsets[2]),
|
||||
);
|
||||
return object;
|
||||
}
|
||||
|
||||
P _deviceAssetEntityDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 1:
|
||||
return (reader.readByteList(offset) ?? []) as P;
|
||||
case 2:
|
||||
return (reader.readDateTime(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _deviceAssetEntityGetId(DeviceAssetEntity object) {
|
||||
return object.id;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _deviceAssetEntityGetLinks(
|
||||
DeviceAssetEntity object,
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
void _deviceAssetEntityAttach(
|
||||
IsarCollection<dynamic> col,
|
||||
Id id,
|
||||
DeviceAssetEntity object,
|
||||
) {}
|
||||
|
||||
extension DeviceAssetEntityByIndex on IsarCollection<DeviceAssetEntity> {
|
||||
Future<DeviceAssetEntity?> getByAssetId(String assetId) {
|
||||
return getByIndex(r'assetId', [assetId]);
|
||||
}
|
||||
|
||||
DeviceAssetEntity? getByAssetIdSync(String assetId) {
|
||||
return getByIndexSync(r'assetId', [assetId]);
|
||||
}
|
||||
|
||||
Future<bool> deleteByAssetId(String assetId) {
|
||||
return deleteByIndex(r'assetId', [assetId]);
|
||||
}
|
||||
|
||||
bool deleteByAssetIdSync(String assetId) {
|
||||
return deleteByIndexSync(r'assetId', [assetId]);
|
||||
}
|
||||
|
||||
Future<List<DeviceAssetEntity?>> getAllByAssetId(List<String> assetIdValues) {
|
||||
final values = assetIdValues.map((e) => [e]).toList();
|
||||
return getAllByIndex(r'assetId', values);
|
||||
}
|
||||
|
||||
List<DeviceAssetEntity?> getAllByAssetIdSync(List<String> assetIdValues) {
|
||||
final values = assetIdValues.map((e) => [e]).toList();
|
||||
return getAllByIndexSync(r'assetId', values);
|
||||
}
|
||||
|
||||
Future<int> deleteAllByAssetId(List<String> assetIdValues) {
|
||||
final values = assetIdValues.map((e) => [e]).toList();
|
||||
return deleteAllByIndex(r'assetId', values);
|
||||
}
|
||||
|
||||
int deleteAllByAssetIdSync(List<String> assetIdValues) {
|
||||
final values = assetIdValues.map((e) => [e]).toList();
|
||||
return deleteAllByIndexSync(r'assetId', values);
|
||||
}
|
||||
|
||||
Future<Id> putByAssetId(DeviceAssetEntity object) {
|
||||
return putByIndex(r'assetId', object);
|
||||
}
|
||||
|
||||
Id putByAssetIdSync(DeviceAssetEntity object, {bool saveLinks = true}) {
|
||||
return putByIndexSync(r'assetId', object, saveLinks: saveLinks);
|
||||
}
|
||||
|
||||
Future<List<Id>> putAllByAssetId(List<DeviceAssetEntity> objects) {
|
||||
return putAllByIndex(r'assetId', objects);
|
||||
}
|
||||
|
||||
List<Id> putAllByAssetIdSync(
|
||||
List<DeviceAssetEntity> objects, {
|
||||
bool saveLinks = true,
|
||||
}) {
|
||||
return putAllByIndexSync(r'assetId', objects, saveLinks: saveLinks);
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceAssetEntityQueryWhereSort
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QWhere> {
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhere> anyId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceAssetEntityQueryWhere
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QWhereClause> {
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
idEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IdWhereClause.between(lower: id, upper: id));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
idNotEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
idGreaterThan(Id id, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
idLessThan(Id id, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
idBetween(
|
||||
Id lowerId,
|
||||
Id upperId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(
|
||||
lower: lowerId,
|
||||
includeLower: includeLower,
|
||||
upper: upperId,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
assetIdEqualTo(String assetId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IndexWhereClause.equalTo(indexName: r'assetId', value: [assetId]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
assetIdNotEqualTo(String assetId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'assetId',
|
||||
lower: [],
|
||||
upper: [assetId],
|
||||
includeUpper: false,
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'assetId',
|
||||
lower: [assetId],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'assetId',
|
||||
lower: [assetId],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'assetId',
|
||||
lower: [],
|
||||
upper: [assetId],
|
||||
includeUpper: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
hashEqualTo(List<int> hash) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IndexWhereClause.equalTo(indexName: r'hash', value: [hash]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterWhereClause>
|
||||
hashNotEqualTo(List<int> hash) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [],
|
||||
upper: [hash],
|
||||
includeUpper: false,
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [hash],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [hash],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
),
|
||||
)
|
||||
.addWhereClause(
|
||||
IndexWhereClause.between(
|
||||
indexName: r'hash',
|
||||
lower: [],
|
||||
upper: [hash],
|
||||
includeUpper: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceAssetEntityQueryFilter
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QFilterCondition> {
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdEqualTo(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(
|
||||
property: r'assetId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'assetId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdLessThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'assetId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'assetId',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdStartsWith(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.startsWith(
|
||||
property: r'assetId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdEndsWith(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.endsWith(
|
||||
property: r'assetId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdContains(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.contains(
|
||||
property: r'assetId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdMatches(String pattern, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.matches(
|
||||
property: r'assetId',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'assetId', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
assetIdIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(property: r'assetId', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashElementEqualTo(int value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'hash', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashElementGreaterThan(int value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'hash',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashElementLessThan(int value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'hash',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashElementBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'hash',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashLengthEqualTo(int length) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', length, true, length, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, false, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashLengthLessThan(int length, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', 0, true, length, include);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashLengthGreaterThan(int length, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(r'hash', length, include, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
hashLengthBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'hash',
|
||||
lower,
|
||||
includeLower,
|
||||
upper,
|
||||
includeUpper,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
idEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'id', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
idGreaterThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
idLessThan(Id value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
idBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
modifiedTimeEqualTo(DateTime value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'modifiedTime', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
modifiedTimeGreaterThan(DateTime value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'modifiedTime',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
modifiedTimeLessThan(DateTime value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'modifiedTime',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterFilterCondition>
|
||||
modifiedTimeBetween(
|
||||
DateTime lower,
|
||||
DateTime upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'modifiedTime',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceAssetEntityQueryObject
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QFilterCondition> {}
|
||||
|
||||
extension DeviceAssetEntityQueryLinks
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QFilterCondition> {}
|
||||
|
||||
extension DeviceAssetEntityQuerySortBy
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QSortBy> {
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
sortByAssetId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
sortByAssetIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetId', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
sortByModifiedTime() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'modifiedTime', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
sortByModifiedTimeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'modifiedTime', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceAssetEntityQuerySortThenBy
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QSortThenBy> {
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
thenByAssetId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
thenByAssetIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'assetId', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
thenByModifiedTime() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'modifiedTime', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QAfterSortBy>
|
||||
thenByModifiedTimeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'modifiedTime', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceAssetEntityQueryWhereDistinct
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QDistinct> {
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QDistinct>
|
||||
distinctByAssetId({bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'assetId', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QDistinct>
|
||||
distinctByHash() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'hash');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QDistinct>
|
||||
distinctByModifiedTime() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'modifiedTime');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceAssetEntityQueryProperty
|
||||
on QueryBuilder<DeviceAssetEntity, DeviceAssetEntity, QQueryProperty> {
|
||||
QueryBuilder<DeviceAssetEntity, int, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, String, QQueryOperations> assetIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'assetId');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, List<int>, QQueryOperations> hashProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'hash');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DeviceAssetEntity, DateTime, QQueryOperations>
|
||||
modifiedTimeProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'modifiedTime');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -4,96 +4,6 @@ import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||
import 'package:immich_mobile/infrastructure/utils/exif.converter.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'exif.entity.g.dart';
|
||||
|
||||
/// Exif information 1:1 relation with Asset
|
||||
@Collection(inheritance: false)
|
||||
class ExifInfo {
|
||||
final Id? id;
|
||||
final int? fileSize;
|
||||
final DateTime? dateTimeOriginal;
|
||||
final String? timeZone;
|
||||
final String? make;
|
||||
final String? model;
|
||||
final String? lens;
|
||||
final float? f;
|
||||
final float? mm;
|
||||
final short? iso;
|
||||
final float? exposureSeconds;
|
||||
final float? lat;
|
||||
final float? long;
|
||||
final String? city;
|
||||
final String? state;
|
||||
final String? country;
|
||||
final String? description;
|
||||
final String? orientation;
|
||||
|
||||
const ExifInfo({
|
||||
this.id,
|
||||
this.fileSize,
|
||||
this.dateTimeOriginal,
|
||||
this.timeZone,
|
||||
this.make,
|
||||
this.model,
|
||||
this.lens,
|
||||
this.f,
|
||||
this.mm,
|
||||
this.iso,
|
||||
this.exposureSeconds,
|
||||
this.lat,
|
||||
this.long,
|
||||
this.city,
|
||||
this.state,
|
||||
this.country,
|
||||
this.description,
|
||||
this.orientation,
|
||||
});
|
||||
|
||||
static ExifInfo fromDto(domain.ExifInfo dto) => ExifInfo(
|
||||
id: dto.assetId,
|
||||
fileSize: dto.fileSize,
|
||||
dateTimeOriginal: dto.dateTimeOriginal,
|
||||
timeZone: dto.timeZone,
|
||||
make: dto.make,
|
||||
model: dto.model,
|
||||
lens: dto.lens,
|
||||
f: dto.f,
|
||||
mm: dto.mm,
|
||||
iso: dto.iso?.toInt(),
|
||||
exposureSeconds: dto.exposureSeconds,
|
||||
lat: dto.latitude,
|
||||
long: dto.longitude,
|
||||
city: dto.city,
|
||||
state: dto.state,
|
||||
country: dto.country,
|
||||
description: dto.description,
|
||||
orientation: dto.orientation,
|
||||
);
|
||||
|
||||
domain.ExifInfo toDto() => domain.ExifInfo(
|
||||
assetId: id,
|
||||
fileSize: fileSize,
|
||||
description: description,
|
||||
orientation: orientation,
|
||||
timeZone: timeZone,
|
||||
dateTimeOriginal: dateTimeOriginal,
|
||||
isFlipped: ExifDtoConverter.isOrientationFlipped(orientation),
|
||||
latitude: lat,
|
||||
longitude: long,
|
||||
city: city,
|
||||
state: state,
|
||||
country: country,
|
||||
make: make,
|
||||
model: model,
|
||||
lens: lens,
|
||||
f: f,
|
||||
mm: mm,
|
||||
iso: iso?.toInt(),
|
||||
exposureSeconds: exposureSeconds,
|
||||
);
|
||||
}
|
||||
|
||||
@TableIndex.sql('CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)')
|
||||
class RemoteExifEntity extends Table with DriftDefaultsMixin {
|
||||
@ -152,6 +62,8 @@ extension RemoteExifEntityDataDomainEx on RemoteExifEntityData {
|
||||
fileSize: fileSize,
|
||||
dateTimeOriginal: dateTimeOriginal,
|
||||
rating: rating,
|
||||
width: width,
|
||||
height: height,
|
||||
timeZone: timeZone,
|
||||
make: make,
|
||||
model: model,
|
||||
|
||||
3200
mobile/lib/infrastructure/entities/exif.entity.g.dart
generated
3200
mobile/lib/infrastructure/entities/exif.entity.g.dart
generated
File diff suppressed because it is too large
Load Diff
@ -1,18 +1,5 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'store.entity.g.dart';
|
||||
|
||||
/// Internal class for `Store`, do not use elsewhere.
|
||||
@Collection(inheritance: false)
|
||||
class StoreValue {
|
||||
final Id id;
|
||||
final int? intValue;
|
||||
final String? strValue;
|
||||
|
||||
const StoreValue(this.id, {this.intValue, this.strValue});
|
||||
}
|
||||
|
||||
class StoreEntity extends Table with DriftDefaultsMixin {
|
||||
IntColumn get id => integer()();
|
||||
|
||||
596
mobile/lib/infrastructure/entities/store.entity.g.dart
generated
596
mobile/lib/infrastructure/entities/store.entity.g.dart
generated
@ -1,596 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'store.entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types
|
||||
|
||||
extension GetStoreValueCollection on Isar {
|
||||
IsarCollection<StoreValue> get storeValues => this.collection();
|
||||
}
|
||||
|
||||
const StoreValueSchema = CollectionSchema(
|
||||
name: r'StoreValue',
|
||||
id: 902899285492123510,
|
||||
properties: {
|
||||
r'intValue': PropertySchema(id: 0, name: r'intValue', type: IsarType.long),
|
||||
r'strValue': PropertySchema(
|
||||
id: 1,
|
||||
name: r'strValue',
|
||||
type: IsarType.string,
|
||||
),
|
||||
},
|
||||
|
||||
estimateSize: _storeValueEstimateSize,
|
||||
serialize: _storeValueSerialize,
|
||||
deserialize: _storeValueDeserialize,
|
||||
deserializeProp: _storeValueDeserializeProp,
|
||||
idName: r'id',
|
||||
indexes: {},
|
||||
links: {},
|
||||
embeddedSchemas: {},
|
||||
|
||||
getId: _storeValueGetId,
|
||||
getLinks: _storeValueGetLinks,
|
||||
attach: _storeValueAttach,
|
||||
version: '3.3.0-dev.3',
|
||||
);
|
||||
|
||||
int _storeValueEstimateSize(
|
||||
StoreValue object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
{
|
||||
final value = object.strValue;
|
||||
if (value != null) {
|
||||
bytesCount += 3 + value.length * 3;
|
||||
}
|
||||
}
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _storeValueSerialize(
|
||||
StoreValue object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeLong(offsets[0], object.intValue);
|
||||
writer.writeString(offsets[1], object.strValue);
|
||||
}
|
||||
|
||||
StoreValue _storeValueDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = StoreValue(
|
||||
id,
|
||||
intValue: reader.readLongOrNull(offsets[0]),
|
||||
strValue: reader.readStringOrNull(offsets[1]),
|
||||
);
|
||||
return object;
|
||||
}
|
||||
|
||||
P _storeValueDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readLongOrNull(offset)) as P;
|
||||
case 1:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _storeValueGetId(StoreValue object) {
|
||||
return object.id;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _storeValueGetLinks(StoreValue object) {
|
||||
return [];
|
||||
}
|
||||
|
||||
void _storeValueAttach(IsarCollection<dynamic> col, Id id, StoreValue object) {}
|
||||
|
||||
extension StoreValueQueryWhereSort
|
||||
on QueryBuilder<StoreValue, StoreValue, QWhere> {
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterWhere> anyId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreValueQueryWhere
|
||||
on QueryBuilder<StoreValue, StoreValue, QWhereClause> {
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterWhereClause> idEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IdWhereClause.between(lower: id, upper: id));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterWhereClause> idNotEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterWhereClause> idGreaterThan(
|
||||
Id id, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterWhereClause> idLessThan(
|
||||
Id id, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterWhereClause> idBetween(
|
||||
Id lowerId,
|
||||
Id upperId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.between(
|
||||
lower: lowerId,
|
||||
includeLower: includeLower,
|
||||
upper: upperId,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreValueQueryFilter
|
||||
on QueryBuilder<StoreValue, StoreValue, QFilterCondition> {
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> idEqualTo(
|
||||
Id value,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'id', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> idGreaterThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> idLessThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> idBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> intValueIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNull(property: r'intValue'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition>
|
||||
intValueIsNotNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNotNull(property: r'intValue'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> intValueEqualTo(
|
||||
int? value,
|
||||
) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'intValue', value: value),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition>
|
||||
intValueGreaterThan(int? value, {bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'intValue',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> intValueLessThan(
|
||||
int? value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'intValue',
|
||||
value: value,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> intValueBetween(
|
||||
int? lower,
|
||||
int? upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'intValue',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> strValueIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNull(property: r'strValue'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition>
|
||||
strValueIsNotNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
const FilterCondition.isNotNull(property: r'strValue'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> strValueEqualTo(
|
||||
String? value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(
|
||||
property: r'strValue',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition>
|
||||
strValueGreaterThan(
|
||||
String? value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'strValue',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> strValueLessThan(
|
||||
String? value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'strValue',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> strValueBetween(
|
||||
String? lower,
|
||||
String? upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.between(
|
||||
property: r'strValue',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition>
|
||||
strValueStartsWith(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.startsWith(
|
||||
property: r'strValue',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> strValueEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.endsWith(
|
||||
property: r'strValue',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> strValueContains(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.contains(
|
||||
property: r'strValue',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition> strValueMatches(
|
||||
String pattern, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.matches(
|
||||
property: r'strValue',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition>
|
||||
strValueIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.equalTo(property: r'strValue', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterFilterCondition>
|
||||
strValueIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(
|
||||
FilterCondition.greaterThan(property: r'strValue', value: ''),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreValueQueryObject
|
||||
on QueryBuilder<StoreValue, StoreValue, QFilterCondition> {}
|
||||
|
||||
extension StoreValueQueryLinks
|
||||
on QueryBuilder<StoreValue, StoreValue, QFilterCondition> {}
|
||||
|
||||
extension StoreValueQuerySortBy
|
||||
on QueryBuilder<StoreValue, StoreValue, QSortBy> {
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> sortByIntValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'intValue', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> sortByIntValueDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'intValue', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> sortByStrValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'strValue', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> sortByStrValueDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'strValue', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreValueQuerySortThenBy
|
||||
on QueryBuilder<StoreValue, StoreValue, QSortThenBy> {
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> thenByIntValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'intValue', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> thenByIntValueDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'intValue', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> thenByStrValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'strValue', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QAfterSortBy> thenByStrValueDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'strValue', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreValueQueryWhereDistinct
|
||||
on QueryBuilder<StoreValue, StoreValue, QDistinct> {
|
||||
QueryBuilder<StoreValue, StoreValue, QDistinct> distinctByIntValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'intValue');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, StoreValue, QDistinct> distinctByStrValue({
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'strValue', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreValueQueryProperty
|
||||
on QueryBuilder<StoreValue, StoreValue, QQueryProperty> {
|
||||
QueryBuilder<StoreValue, int, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, int?, QQueryOperations> intValueProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'intValue');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<StoreValue, String?, QQueryOperations> strValueProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'strValue');
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,79 +1,6 @@
|
||||
import 'package:drift/drift.dart' hide Index;
|
||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||
import 'package:immich_mobile/utils/hash.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'user.entity.g.dart';
|
||||
|
||||
@Collection(inheritance: false)
|
||||
class User {
|
||||
Id get isarId => fastHash(id);
|
||||
@Index(unique: true, replace: false, type: IndexType.hash)
|
||||
final String id;
|
||||
final DateTime updatedAt;
|
||||
final String email;
|
||||
final String name;
|
||||
final bool isPartnerSharedBy;
|
||||
final bool isPartnerSharedWith;
|
||||
final bool isAdmin;
|
||||
final String profileImagePath;
|
||||
@Enumerated(EnumType.ordinal)
|
||||
final AvatarColor avatarColor;
|
||||
final bool memoryEnabled;
|
||||
final bool inTimeline;
|
||||
final int quotaUsageInBytes;
|
||||
final int quotaSizeInBytes;
|
||||
|
||||
const User({
|
||||
required this.id,
|
||||
required this.updatedAt,
|
||||
required this.email,
|
||||
required this.name,
|
||||
required this.isAdmin,
|
||||
this.isPartnerSharedBy = false,
|
||||
this.isPartnerSharedWith = false,
|
||||
this.profileImagePath = '',
|
||||
this.avatarColor = AvatarColor.primary,
|
||||
this.memoryEnabled = true,
|
||||
this.inTimeline = false,
|
||||
this.quotaUsageInBytes = 0,
|
||||
this.quotaSizeInBytes = 0,
|
||||
});
|
||||
|
||||
static User fromDto(UserDto dto) => User(
|
||||
id: dto.id,
|
||||
updatedAt: dto.updatedAt ?? DateTime(2025),
|
||||
email: dto.email,
|
||||
name: dto.name,
|
||||
isAdmin: dto.isAdmin,
|
||||
isPartnerSharedBy: dto.isPartnerSharedBy,
|
||||
isPartnerSharedWith: dto.isPartnerSharedWith,
|
||||
profileImagePath: dto.hasProfileImage ? "HAS_PROFILE_IMAGE" : "",
|
||||
avatarColor: dto.avatarColor,
|
||||
memoryEnabled: dto.memoryEnabled,
|
||||
inTimeline: dto.inTimeline,
|
||||
quotaUsageInBytes: dto.quotaUsageInBytes,
|
||||
quotaSizeInBytes: dto.quotaSizeInBytes,
|
||||
);
|
||||
|
||||
UserDto toDto() => UserDto(
|
||||
id: id,
|
||||
email: email,
|
||||
name: name,
|
||||
isAdmin: isAdmin,
|
||||
updatedAt: updatedAt,
|
||||
avatarColor: avatarColor,
|
||||
memoryEnabled: memoryEnabled,
|
||||
inTimeline: inTimeline,
|
||||
isPartnerSharedBy: isPartnerSharedBy,
|
||||
isPartnerSharedWith: isPartnerSharedWith,
|
||||
hasProfileImage: profileImagePath.isNotEmpty,
|
||||
profileChangedAt: updatedAt,
|
||||
quotaUsageInBytes: quotaUsageInBytes,
|
||||
quotaSizeInBytes: quotaSizeInBytes,
|
||||
);
|
||||
}
|
||||
|
||||
class UserEntity extends Table with DriftDefaultsMixin {
|
||||
const UserEntity();
|
||||
|
||||
1854
mobile/lib/infrastructure/entities/user.entity.g.dart
generated
1854
mobile/lib/infrastructure/entities/user.entity.g.dart
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,6 @@ import 'dart:async';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift_flutter/drift_flutter.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/db.interface.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/asset_edit.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.dart';
|
||||
@ -27,22 +26,6 @@ import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.steps.dart';
|
||||
import 'package:isar/isar.dart' hide Index;
|
||||
|
||||
// #zoneTxn is the symbol used by Isar to mark a transaction within the current zone
|
||||
// ref: isar/isar_common.dart
|
||||
const Symbol _kzoneTxn = #zoneTxn;
|
||||
|
||||
class IsarDatabaseRepository implements IDatabaseRepository {
|
||||
final Isar _db;
|
||||
const IsarDatabaseRepository(Isar db) : _db = db;
|
||||
|
||||
// Isar do not support nested transactions. This is a workaround to prevent us from making nested transactions
|
||||
// Reuse the current transaction if it is already active, else start a new transaction
|
||||
@override
|
||||
Future<T> transaction<T>(Future<T> Function() callback) =>
|
||||
Zone.current[_kzoneTxn] == null ? _db.writeTxn(callback) : callback();
|
||||
}
|
||||
|
||||
@DriftDatabase(
|
||||
tables: [
|
||||
@ -70,7 +53,7 @@ class IsarDatabaseRepository implements IDatabaseRepository {
|
||||
],
|
||||
include: {'package:immich_mobile/infrastructure/entities/merged_asset.drift'},
|
||||
)
|
||||
class Drift extends $Drift implements IDatabaseRepository {
|
||||
class Drift extends $Drift {
|
||||
Drift([QueryExecutor? executor])
|
||||
: super(executor ?? driftDatabase(name: 'immich', native: const DriftNativeOptions(shareAcrossIsolates: true)));
|
||||
|
||||
@ -261,10 +244,9 @@ class Drift extends $Drift implements IDatabaseRepository {
|
||||
);
|
||||
}
|
||||
|
||||
class DriftDatabaseRepository implements IDatabaseRepository {
|
||||
class DriftDatabaseRepository {
|
||||
final Drift _db;
|
||||
const DriftDatabaseRepository(this._db);
|
||||
|
||||
@override
|
||||
Future<T> transaction<T>(Future<T> Function() callback) => _db.transaction(callback);
|
||||
}
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
import 'package:immich_mobile/domain/models/device_asset.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/device_asset.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
class IsarDeviceAssetRepository extends IsarDatabaseRepository {
|
||||
final Isar _db;
|
||||
|
||||
const IsarDeviceAssetRepository(this._db) : super(_db);
|
||||
|
||||
Future<void> deleteIds(List<String> ids) {
|
||||
return transaction(() async {
|
||||
await _db.deviceAssetEntitys.deleteAllByAssetId(ids.toList());
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<DeviceAsset>> getByIds(List<String> localIds) {
|
||||
return _db.deviceAssetEntitys
|
||||
.where()
|
||||
.anyOf(localIds, (query, id) => query.assetIdEqualTo(id))
|
||||
.findAll()
|
||||
.then((value) => value.map((e) => e.toModel()).toList());
|
||||
}
|
||||
|
||||
Future<bool> updateAll(List<DeviceAsset> assetHash) {
|
||||
return transaction(() async {
|
||||
await _db.deviceAssetEntitys.putAll(assetHash.map(DeviceAssetEntity.fromDto).toList());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart' as entity;
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
class IsarExifRepository extends IsarDatabaseRepository {
|
||||
final Isar _db;
|
||||
|
||||
const IsarExifRepository(this._db) : super(_db);
|
||||
|
||||
Future<void> delete(int assetId) async {
|
||||
await transaction(() async {
|
||||
await _db.exifInfos.delete(assetId);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> deleteAll() async {
|
||||
await transaction(() async {
|
||||
await _db.exifInfos.clear();
|
||||
});
|
||||
}
|
||||
|
||||
Future<ExifInfo?> get(int assetId) async {
|
||||
return (await _db.exifInfos.get(assetId))?.toDto();
|
||||
}
|
||||
|
||||
Future<ExifInfo> update(ExifInfo exifInfo) {
|
||||
return transaction(() async {
|
||||
await _db.exifInfos.put(entity.ExifInfo.fromDto(exifInfo));
|
||||
return exifInfo;
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<ExifInfo>> updateAll(List<ExifInfo> exifInfos) {
|
||||
return transaction(() async {
|
||||
await _db.exifInfos.putAll(exifInfos.map(entity.ExifInfo.fromDto).toList());
|
||||
return exifInfos;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,10 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift_flutter/drift_flutter.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/db.interface.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/log.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/logger_db.repository.drift.dart';
|
||||
|
||||
@DriftDatabase(tables: [LogMessageEntity])
|
||||
class DriftLogger extends $DriftLogger implements IDatabaseRepository {
|
||||
class DriftLogger extends $DriftLogger {
|
||||
DriftLogger([QueryExecutor? executor])
|
||||
: super(
|
||||
executor ?? driftDatabase(name: 'immich_logs', native: const DriftNativeOptions(shareAcrossIsolates: true)),
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/asset_edit.model.dart';
|
||||
import 'package:immich_mobile/domain/models/exif.model.dart';
|
||||
import 'package:immich_mobile/domain/models/stack.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart' hide ExifInfo;
|
||||
import 'package:immich_mobile/infrastructure/entities/asset_edit.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart';
|
||||
@ -264,4 +266,11 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
|
||||
Future<int> getCount() {
|
||||
return _db.managers.remoteAssetEntity.count();
|
||||
}
|
||||
|
||||
Future<List<AssetEdit>> getAssetEdits(String assetId) {
|
||||
final query = _db.assetEditEntity.select()
|
||||
..where((row) => row.assetId.equals(assetId) & row.action.equals(AssetEditAction.other.index).not())
|
||||
..orderBy([(row) => OrderingTerm.asc(row.sequence)]);
|
||||
return query.map((row) => row.toDto()!).get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,150 +1,42 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/store.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/store.entity.drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/user.repository.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
// Temporary interface until Isar is removed to make the service work with both Isar and Sqlite
|
||||
abstract class IStoreRepository {
|
||||
Future<bool> deleteAll();
|
||||
Stream<List<StoreDto<Object>>> watchAll();
|
||||
Future<void> delete<T>(StoreKey<T> key);
|
||||
Future<bool> upsert<T>(StoreKey<T> key, T value);
|
||||
Future<T?> tryGet<T>(StoreKey<T> key);
|
||||
Stream<T?> watch<T>(StoreKey<T> key);
|
||||
Future<List<StoreDto<Object>>> getAll();
|
||||
}
|
||||
|
||||
class IsarStoreRepository extends IsarDatabaseRepository implements IStoreRepository {
|
||||
final Isar _db;
|
||||
final validStoreKeys = StoreKey.values.map((e) => e.id).toSet();
|
||||
|
||||
IsarStoreRepository(super.db) : _db = db;
|
||||
|
||||
@override
|
||||
Future<bool> deleteAll() async {
|
||||
return await transaction(() async {
|
||||
await _db.storeValues.clear();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<List<StoreDto<Object>>> watchAll() {
|
||||
return _db.storeValues
|
||||
.filter()
|
||||
.anyOf(validStoreKeys, (query, id) => query.idEqualTo(id))
|
||||
.watch(fireImmediately: true)
|
||||
.asyncMap((entities) => Future.wait(entities.map((entity) => _toUpdateEvent(entity))));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> delete<T>(StoreKey<T> key) async {
|
||||
return await transaction(() async => await _db.storeValues.delete(key.id));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> upsert<T>(StoreKey<T> key, T value) async {
|
||||
return await transaction(() async {
|
||||
await _db.storeValues.put(await _fromValue(key, value));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<T?> tryGet<T>(StoreKey<T> key) async {
|
||||
final entity = (await _db.storeValues.get(key.id));
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
return await _toValue(key, entity);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<T?> watch<T>(StoreKey<T> key) async* {
|
||||
yield* _db.storeValues
|
||||
.watchObject(key.id, fireImmediately: true)
|
||||
.asyncMap((e) async => e == null ? null : await _toValue(key, e));
|
||||
}
|
||||
|
||||
Future<StoreDto<Object>> _toUpdateEvent(StoreValue entity) async {
|
||||
final key = StoreKey.values.firstWhere((e) => e.id == entity.id) as StoreKey<Object>;
|
||||
final value = await _toValue(key, entity);
|
||||
return StoreDto(key, value);
|
||||
}
|
||||
|
||||
Future<T?> _toValue<T>(StoreKey<T> key, StoreValue entity) async =>
|
||||
switch (key.type) {
|
||||
const (int) => entity.intValue,
|
||||
const (String) => entity.strValue,
|
||||
const (bool) => entity.intValue == 1,
|
||||
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
||||
const (UserDto) =>
|
||||
entity.strValue == null ? null : await IsarUserRepository(_db).getByUserId(entity.strValue!),
|
||||
_ => null,
|
||||
}
|
||||
as T?;
|
||||
|
||||
Future<StoreValue> _fromValue<T>(StoreKey<T> key, T value) async {
|
||||
final (int? intValue, String? strValue) = switch (key.type) {
|
||||
const (int) => (value as int, null),
|
||||
const (String) => (null, value as String),
|
||||
const (bool) => ((value as bool) ? 1 : 0, null),
|
||||
const (DateTime) => ((value as DateTime).millisecondsSinceEpoch, null),
|
||||
const (UserDto) => (null, (await IsarUserRepository(_db).update(value as UserDto)).id),
|
||||
_ => throw UnsupportedError("Unsupported primitive type: ${key.type} for key: ${key.name}"),
|
||||
};
|
||||
return StoreValue(key.id, intValue: intValue, strValue: strValue);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<StoreDto<Object>>> getAll() async {
|
||||
final entities = await _db.storeValues.filter().anyOf(validStoreKeys, (query, id) => query.idEqualTo(id)).findAll();
|
||||
return Future.wait(entities.map((e) => _toUpdateEvent(e)).toList());
|
||||
}
|
||||
}
|
||||
|
||||
class DriftStoreRepository extends DriftDatabaseRepository implements IStoreRepository {
|
||||
class DriftStoreRepository extends DriftDatabaseRepository {
|
||||
final Drift _db;
|
||||
final validStoreKeys = StoreKey.values.map((e) => e.id).toSet();
|
||||
|
||||
DriftStoreRepository(super.db) : _db = db;
|
||||
|
||||
@override
|
||||
Future<bool> deleteAll() async {
|
||||
await _db.storeEntity.deleteAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<StoreDto<Object>>> getAll() async {
|
||||
final query = _db.storeEntity.select()..where((entity) => entity.id.isIn(validStoreKeys));
|
||||
return query.asyncMap((entity) => _toUpdateEvent(entity)).get();
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<List<StoreDto<Object>>> watchAll() {
|
||||
final query = _db.storeEntity.select()..where((entity) => entity.id.isIn(validStoreKeys));
|
||||
|
||||
return query.asyncMap((entity) => _toUpdateEvent(entity)).watch();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> delete<T>(StoreKey<T> key) async {
|
||||
await _db.storeEntity.deleteWhere((entity) => entity.id.equals(key.id));
|
||||
return;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> upsert<T>(StoreKey<T> key, T value) async {
|
||||
await _db.storeEntity.insertOnConflictUpdate(await _fromValue(key, value));
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<T?> tryGet<T>(StoreKey<T> key) async {
|
||||
final entity = await _db.managers.storeEntity.filter((entity) => entity.id.equals(key.id)).getSingleOrNull();
|
||||
if (entity == null) {
|
||||
@ -153,7 +45,6 @@ class DriftStoreRepository extends DriftDatabaseRepository implements IStoreRepo
|
||||
return await _toValue(key, entity);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<T?> watch<T>(StoreKey<T> key) async* {
|
||||
final query = _db.storeEntity.select()..where((entity) => entity.id.equals(key.id));
|
||||
|
||||
|
||||
@ -1,72 +1,9 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as entity;
|
||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/user_metadata.repository.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
class IsarUserRepository extends IsarDatabaseRepository {
|
||||
final Isar _db;
|
||||
const IsarUserRepository(super.db) : _db = db;
|
||||
|
||||
Future<void> delete(List<String> ids) async {
|
||||
await transaction(() async {
|
||||
await _db.users.deleteAllById(ids);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> deleteAll() async {
|
||||
await transaction(() async {
|
||||
await _db.users.clear();
|
||||
});
|
||||
}
|
||||
|
||||
Future<List<UserDto>> getAll({SortUserBy? sortBy}) async {
|
||||
return (await _db.users
|
||||
.where()
|
||||
.optional(
|
||||
sortBy != null,
|
||||
(query) => switch (sortBy!) {
|
||||
SortUserBy.id => query.sortById(),
|
||||
},
|
||||
)
|
||||
.findAll())
|
||||
.map((u) => u.toDto())
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<UserDto?> getByUserId(String id) async {
|
||||
return (await _db.users.getById(id))?.toDto();
|
||||
}
|
||||
|
||||
Future<List<UserDto?>> getByUserIds(List<String> ids) async {
|
||||
return (await _db.users.getAllById(ids)).map((u) => u?.toDto()).toList();
|
||||
}
|
||||
|
||||
Future<bool> insert(UserDto user) async {
|
||||
await transaction(() async {
|
||||
await _db.users.put(entity.User.fromDto(user));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<UserDto> update(UserDto user) async {
|
||||
await transaction(() async {
|
||||
await _db.users.put(entity.User.fromDto(user));
|
||||
});
|
||||
return user;
|
||||
}
|
||||
|
||||
Future<bool> updateAll(List<UserDto> users) async {
|
||||
await transaction(() async {
|
||||
await _db.users.putAll(users.map(entity.User.fromDto).toList());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class DriftAuthUserRepository extends DriftDatabaseRepository {
|
||||
final Drift _db;
|
||||
@ -117,6 +54,7 @@ extension on AuthUserEntityData {
|
||||
id: id,
|
||||
email: email,
|
||||
name: name,
|
||||
updatedAt: profileChangedAt,
|
||||
profileChangedAt: profileChangedAt,
|
||||
hasProfileImage: hasProfileImage,
|
||||
avatarColor: avatarColor,
|
||||
|
||||
@ -14,7 +14,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/constants.dart';
|
||||
import 'package:immich_mobile/constants/locales.dart';
|
||||
import 'package:immich_mobile/domain/services/background_worker.service.dart';
|
||||
import 'package:immich_mobile/entities/store.entity.dart';
|
||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||
import 'package:immich_mobile/generated/codegen_loader.g.dart';
|
||||
@ -24,7 +23,6 @@ import 'package:immich_mobile/pages/common/splash_screen.page.dart';
|
||||
import 'package:immich_mobile/platform/background_worker_lock_api.g.dart';
|
||||
import 'package:immich_mobile/providers/app_life_cycle.provider.dart';
|
||||
import 'package:immich_mobile/providers/asset_viewer/share_intent_upload.provider.dart';
|
||||
import 'package:immich_mobile/providers/db.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/platform.provider.dart';
|
||||
import 'package:immich_mobile/providers/locale_provider.dart';
|
||||
@ -32,9 +30,7 @@ import 'package:immich_mobile/providers/routes.provider.dart';
|
||||
import 'package:immich_mobile/providers/theme.provider.dart';
|
||||
import 'package:immich_mobile/routing/app_navigation_observer.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
import 'package:immich_mobile/services/background.service.dart';
|
||||
import 'package:immich_mobile/services/deep_link.service.dart';
|
||||
import 'package:immich_mobile/services/local_notification.service.dart';
|
||||
import 'package:immich_mobile/theme/dynamic_theme.dart';
|
||||
import 'package:immich_mobile/theme/theme_data.dart';
|
||||
import 'package:immich_mobile/utils/bootstrap.dart';
|
||||
@ -53,23 +49,13 @@ void main() async {
|
||||
ImmichWidgetsBinding();
|
||||
unawaited(BackgroundWorkerLockService(BackgroundWorkerLockApi()).lock());
|
||||
await EasyLocalization.ensureInitialized();
|
||||
final (isar, drift, logDb) = await Bootstrap.initDB();
|
||||
await Bootstrap.initDomain(isar, drift, logDb);
|
||||
final (drift, _) = await Bootstrap.initDomain();
|
||||
await initApp();
|
||||
// Warm-up isolate pool for worker manager
|
||||
await workerManagerPatch.init(dynamicSpawning: true, isolatesCount: max(Platform.numberOfProcessors - 1, 5));
|
||||
await migrateDatabaseIfNeeded(isar, drift);
|
||||
await migrateDatabaseIfNeeded();
|
||||
|
||||
runApp(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
dbProvider.overrideWithValue(isar),
|
||||
isarProvider.overrideWithValue(isar),
|
||||
driftProvider.overrideWith(driftOverride(drift)),
|
||||
],
|
||||
child: const MainWidget(),
|
||||
),
|
||||
);
|
||||
runApp(ProviderScope(overrides: [driftProvider.overrideWith(driftOverride(drift))], child: const MainWidget()));
|
||||
} catch (error, stack) {
|
||||
runApp(BootstrapErrorWidget(error: error.toString(), stack: stack.toString()));
|
||||
}
|
||||
@ -176,7 +162,6 @@ class ImmichAppState extends ConsumerState<ImmichApp> with WidgetsBindingObserve
|
||||
}
|
||||
}
|
||||
SystemChrome.setSystemUIOverlayStyle(overlayStyle);
|
||||
await ref.read(localNotificationService).setup();
|
||||
}
|
||||
|
||||
Future<DeepLink> _deepLinkBuilder(PlatformDeepLink deepLink) async {
|
||||
@ -215,20 +200,14 @@ class ImmichAppState extends ConsumerState<ImmichApp> with WidgetsBindingObserve
|
||||
initApp().then((_) => dPrint(() => "App Init Completed"));
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// needs to be delayed so that EasyLocalization is working
|
||||
if (Store.isBetaTimelineEnabled) {
|
||||
ref.read(backgroundServiceProvider).disableService();
|
||||
ref.read(backgroundWorkerFgServiceProvider).enable();
|
||||
if (Platform.isAndroid) {
|
||||
ref
|
||||
.read(backgroundWorkerFgServiceProvider)
|
||||
.saveNotificationMessage(
|
||||
StaticTranslations.instance.uploading_media,
|
||||
StaticTranslations.instance.backup_background_service_default_notification,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ref.read(backgroundWorkerFgServiceProvider).disable();
|
||||
ref.read(backgroundServiceProvider).resumeServiceIfEnabled();
|
||||
ref.read(backgroundWorkerFgServiceProvider).enable();
|
||||
if (Platform.isAndroid) {
|
||||
ref
|
||||
.read(backgroundWorkerFgServiceProvider)
|
||||
.saveNotificationMessage(
|
||||
StaticTranslations.instance.uploading_media,
|
||||
StaticTranslations.instance.backup_background_service_default_notification,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class AlbumAddAssetsResponse {
|
||||
List<String> alreadyInAlbum;
|
||||
int successfullyAdded;
|
||||
|
||||
AlbumAddAssetsResponse({required this.alreadyInAlbum, required this.successfullyAdded});
|
||||
|
||||
AlbumAddAssetsResponse copyWith({List<String>? alreadyInAlbum, int? successfullyAdded}) {
|
||||
return AlbumAddAssetsResponse(
|
||||
alreadyInAlbum: alreadyInAlbum ?? this.alreadyInAlbum,
|
||||
successfullyAdded: successfullyAdded ?? this.successfullyAdded,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{'alreadyInAlbum': alreadyInAlbum, 'successfullyAdded': successfullyAdded};
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
@override
|
||||
String toString() => 'AddAssetsResponse(alreadyInAlbum: $alreadyInAlbum, successfullyAdded: $successfullyAdded)';
|
||||
|
||||
@override
|
||||
bool operator ==(covariant AlbumAddAssetsResponse other) {
|
||||
if (identical(this, other)) return true;
|
||||
final listEquals = const DeepCollectionEquality().equals;
|
||||
|
||||
return listEquals(other.alreadyInAlbum, alreadyInAlbum) && other.successfullyAdded == successfullyAdded;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => alreadyInAlbum.hashCode ^ successfullyAdded.hashCode;
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AlbumViewerPageState {
|
||||
final bool isEditAlbum;
|
||||
final String editTitleText;
|
||||
final String editDescriptionText;
|
||||
|
||||
const AlbumViewerPageState({
|
||||
required this.isEditAlbum,
|
||||
required this.editTitleText,
|
||||
required this.editDescriptionText,
|
||||
});
|
||||
|
||||
AlbumViewerPageState copyWith({bool? isEditAlbum, String? editTitleText, String? editDescriptionText}) {
|
||||
return AlbumViewerPageState(
|
||||
isEditAlbum: isEditAlbum ?? this.isEditAlbum,
|
||||
editTitleText: editTitleText ?? this.editTitleText,
|
||||
editDescriptionText: editDescriptionText ?? this.editDescriptionText,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final result = <String, dynamic>{};
|
||||
|
||||
result.addAll({'isEditAlbum': isEditAlbum});
|
||||
result.addAll({'editTitleText': editTitleText});
|
||||
result.addAll({'editDescriptionText': editDescriptionText});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
factory AlbumViewerPageState.fromMap(Map<String, dynamic> map) {
|
||||
return AlbumViewerPageState(
|
||||
isEditAlbum: map['isEditAlbum'] ?? false,
|
||||
editTitleText: map['editTitleText'] ?? '',
|
||||
editDescriptionText: map['editDescriptionText'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AlbumViewerPageState.fromJson(String source) => AlbumViewerPageState.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'AlbumViewerPageState(isEditAlbum: $isEditAlbum, editTitleText: $editTitleText, editDescriptionText: $editDescriptionText)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is AlbumViewerPageState &&
|
||||
other.isEditAlbum == isEditAlbum &&
|
||||
other.editTitleText == editTitleText &&
|
||||
other.editDescriptionText == editDescriptionText;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => isEditAlbum.hashCode ^ editTitleText.hashCode ^ editDescriptionText.hashCode;
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
|
||||
class AssetSelectionPageResult {
|
||||
final Set<Asset> selectedAssets;
|
||||
|
||||
const AssetSelectionPageResult({required this.selectedAssets});
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
final setEquals = const DeepCollectionEquality().equals;
|
||||
|
||||
return other is AssetSelectionPageResult && setEquals(other.selectedAssets, selectedAssets);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => selectedAssets.hashCode;
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
|
||||
class AssetSelectionState {
|
||||
final bool hasRemote;
|
||||
final bool hasLocal;
|
||||
final bool hasMerged;
|
||||
final int selectedCount;
|
||||
|
||||
const AssetSelectionState({
|
||||
this.hasRemote = false,
|
||||
this.hasLocal = false,
|
||||
this.hasMerged = false,
|
||||
this.selectedCount = 0,
|
||||
});
|
||||
|
||||
AssetSelectionState copyWith({bool? hasRemote, bool? hasLocal, bool? hasMerged, int? selectedCount}) {
|
||||
return AssetSelectionState(
|
||||
hasRemote: hasRemote ?? this.hasRemote,
|
||||
hasLocal: hasLocal ?? this.hasLocal,
|
||||
hasMerged: hasMerged ?? this.hasMerged,
|
||||
selectedCount: selectedCount ?? this.selectedCount,
|
||||
);
|
||||
}
|
||||
|
||||
AssetSelectionState.fromSelection(Set<Asset> selection)
|
||||
: hasLocal = selection.any((e) => e.storage == AssetState.local),
|
||||
hasMerged = selection.any((e) => e.storage == AssetState.merged),
|
||||
hasRemote = selection.any((e) => e.storage == AssetState.remote),
|
||||
selectedCount = selection.length;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'SelectionAssetState(hasRemote: $hasRemote, hasLocal: $hasLocal, hasMerged: $hasMerged, selectedCount: $selectedCount)';
|
||||
|
||||
@override
|
||||
bool operator ==(covariant AssetSelectionState other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other.hasRemote == hasRemote &&
|
||||
other.hasLocal == hasLocal &&
|
||||
other.hasMerged == hasMerged &&
|
||||
other.selectedCount == selectedCount;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => hasRemote.hashCode ^ hasLocal.hashCode ^ hasMerged.hashCode ^ selectedCount.hashCode;
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
import 'package:immich_mobile/entities/album.entity.dart';
|
||||
|
||||
class AvailableAlbum {
|
||||
final Album album;
|
||||
final int assetCount;
|
||||
final DateTime? lastBackup;
|
||||
const AvailableAlbum({required this.album, required this.assetCount, this.lastBackup});
|
||||
|
||||
AvailableAlbum copyWith({Album? album, int? assetCount, DateTime? lastBackup}) {
|
||||
return AvailableAlbum(
|
||||
album: album ?? this.album,
|
||||
assetCount: assetCount ?? this.assetCount,
|
||||
lastBackup: lastBackup ?? this.lastBackup,
|
||||
);
|
||||
}
|
||||
|
||||
String get name => album.name;
|
||||
|
||||
String get id => album.localId!;
|
||||
|
||||
bool get isAll => album.isAll;
|
||||
|
||||
@override
|
||||
String toString() => 'AvailableAlbum(albumEntity: $album, lastBackup: $lastBackup)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is AvailableAlbum && other.album == album;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => album.hashCode;
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
|
||||
class BackupCandidate {
|
||||
BackupCandidate({required this.asset, required this.albumNames});
|
||||
|
||||
Asset asset;
|
||||
List<String> albumNames;
|
||||
|
||||
@override
|
||||
int get hashCode => asset.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (other is! BackupCandidate) {
|
||||
return false;
|
||||
}
|
||||
return asset == other.asset;
|
||||
}
|
||||
}
|
||||
@ -1,173 +0,0 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:immich_mobile/models/backup/backup_candidate.model.dart';
|
||||
|
||||
import 'package:immich_mobile/models/backup/available_album.model.dart';
|
||||
import 'package:immich_mobile/models/backup/current_upload_asset.model.dart';
|
||||
import 'package:immich_mobile/models/server_info/server_disk_info.model.dart';
|
||||
|
||||
enum BackUpProgressEnum { idle, inProgress, manualInProgress, inBackground, done }
|
||||
|
||||
class BackUpState {
|
||||
// enum
|
||||
final BackUpProgressEnum backupProgress;
|
||||
final List<String> allAssetsInDatabase;
|
||||
final double progressInPercentage;
|
||||
final String progressInFileSize;
|
||||
final double progressInFileSpeed;
|
||||
final List<double> progressInFileSpeeds;
|
||||
final DateTime progressInFileSpeedUpdateTime;
|
||||
final int progressInFileSpeedUpdateSentBytes;
|
||||
final double iCloudDownloadProgress;
|
||||
final ServerDiskInfo serverInfo;
|
||||
final bool autoBackup;
|
||||
final bool backgroundBackup;
|
||||
final bool backupRequireWifi;
|
||||
final bool backupRequireCharging;
|
||||
final int backupTriggerDelay;
|
||||
|
||||
/// All available albums on the device
|
||||
final List<AvailableAlbum> availableAlbums;
|
||||
final Set<AvailableAlbum> selectedBackupAlbums;
|
||||
final Set<AvailableAlbum> excludedBackupAlbums;
|
||||
|
||||
/// Assets that are not overlapping in selected backup albums and excluded backup albums
|
||||
final Set<BackupCandidate> allUniqueAssets;
|
||||
|
||||
/// All assets from the selected albums that have been backup
|
||||
final Set<String> selectedAlbumsBackupAssetsIds;
|
||||
|
||||
// Current Backup Asset
|
||||
final CurrentUploadAsset currentUploadAsset;
|
||||
|
||||
const BackUpState({
|
||||
required this.backupProgress,
|
||||
required this.allAssetsInDatabase,
|
||||
required this.progressInPercentage,
|
||||
required this.progressInFileSize,
|
||||
required this.progressInFileSpeed,
|
||||
required this.progressInFileSpeeds,
|
||||
required this.progressInFileSpeedUpdateTime,
|
||||
required this.progressInFileSpeedUpdateSentBytes,
|
||||
required this.iCloudDownloadProgress,
|
||||
required this.serverInfo,
|
||||
required this.autoBackup,
|
||||
required this.backgroundBackup,
|
||||
required this.backupRequireWifi,
|
||||
required this.backupRequireCharging,
|
||||
required this.backupTriggerDelay,
|
||||
required this.availableAlbums,
|
||||
required this.selectedBackupAlbums,
|
||||
required this.excludedBackupAlbums,
|
||||
required this.allUniqueAssets,
|
||||
required this.selectedAlbumsBackupAssetsIds,
|
||||
required this.currentUploadAsset,
|
||||
});
|
||||
|
||||
BackUpState copyWith({
|
||||
BackUpProgressEnum? backupProgress,
|
||||
List<String>? allAssetsInDatabase,
|
||||
double? progressInPercentage,
|
||||
String? progressInFileSize,
|
||||
double? progressInFileSpeed,
|
||||
List<double>? progressInFileSpeeds,
|
||||
DateTime? progressInFileSpeedUpdateTime,
|
||||
int? progressInFileSpeedUpdateSentBytes,
|
||||
double? iCloudDownloadProgress,
|
||||
ServerDiskInfo? serverInfo,
|
||||
bool? autoBackup,
|
||||
bool? backgroundBackup,
|
||||
bool? backupRequireWifi,
|
||||
bool? backupRequireCharging,
|
||||
int? backupTriggerDelay,
|
||||
List<AvailableAlbum>? availableAlbums,
|
||||
Set<AvailableAlbum>? selectedBackupAlbums,
|
||||
Set<AvailableAlbum>? excludedBackupAlbums,
|
||||
Set<BackupCandidate>? allUniqueAssets,
|
||||
Set<String>? selectedAlbumsBackupAssetsIds,
|
||||
CurrentUploadAsset? currentUploadAsset,
|
||||
}) {
|
||||
return BackUpState(
|
||||
backupProgress: backupProgress ?? this.backupProgress,
|
||||
allAssetsInDatabase: allAssetsInDatabase ?? this.allAssetsInDatabase,
|
||||
progressInPercentage: progressInPercentage ?? this.progressInPercentage,
|
||||
progressInFileSize: progressInFileSize ?? this.progressInFileSize,
|
||||
progressInFileSpeed: progressInFileSpeed ?? this.progressInFileSpeed,
|
||||
progressInFileSpeeds: progressInFileSpeeds ?? this.progressInFileSpeeds,
|
||||
progressInFileSpeedUpdateTime: progressInFileSpeedUpdateTime ?? this.progressInFileSpeedUpdateTime,
|
||||
progressInFileSpeedUpdateSentBytes: progressInFileSpeedUpdateSentBytes ?? this.progressInFileSpeedUpdateSentBytes,
|
||||
iCloudDownloadProgress: iCloudDownloadProgress ?? this.iCloudDownloadProgress,
|
||||
serverInfo: serverInfo ?? this.serverInfo,
|
||||
autoBackup: autoBackup ?? this.autoBackup,
|
||||
backgroundBackup: backgroundBackup ?? this.backgroundBackup,
|
||||
backupRequireWifi: backupRequireWifi ?? this.backupRequireWifi,
|
||||
backupRequireCharging: backupRequireCharging ?? this.backupRequireCharging,
|
||||
backupTriggerDelay: backupTriggerDelay ?? this.backupTriggerDelay,
|
||||
availableAlbums: availableAlbums ?? this.availableAlbums,
|
||||
selectedBackupAlbums: selectedBackupAlbums ?? this.selectedBackupAlbums,
|
||||
excludedBackupAlbums: excludedBackupAlbums ?? this.excludedBackupAlbums,
|
||||
allUniqueAssets: allUniqueAssets ?? this.allUniqueAssets,
|
||||
selectedAlbumsBackupAssetsIds: selectedAlbumsBackupAssetsIds ?? this.selectedAlbumsBackupAssetsIds,
|
||||
currentUploadAsset: currentUploadAsset ?? this.currentUploadAsset,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BackUpState(backupProgress: $backupProgress, allAssetsInDatabase: $allAssetsInDatabase, progressInPercentage: $progressInPercentage, progressInFileSize: $progressInFileSize, progressInFileSpeed: $progressInFileSpeed, progressInFileSpeeds: $progressInFileSpeeds, progressInFileSpeedUpdateTime: $progressInFileSpeedUpdateTime, progressInFileSpeedUpdateSentBytes: $progressInFileSpeedUpdateSentBytes, iCloudDownloadProgress: $iCloudDownloadProgress, serverInfo: $serverInfo, autoBackup: $autoBackup, backgroundBackup: $backgroundBackup, backupRequireWifi: $backupRequireWifi, backupRequireCharging: $backupRequireCharging, backupTriggerDelay: $backupTriggerDelay, availableAlbums: $availableAlbums, selectedBackupAlbums: $selectedBackupAlbums, excludedBackupAlbums: $excludedBackupAlbums, allUniqueAssets: $allUniqueAssets, selectedAlbumsBackupAssetsIds: $selectedAlbumsBackupAssetsIds, currentUploadAsset: $currentUploadAsset)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(covariant BackUpState other) {
|
||||
if (identical(this, other)) return true;
|
||||
final collectionEquals = const DeepCollectionEquality().equals;
|
||||
|
||||
return other.backupProgress == backupProgress &&
|
||||
collectionEquals(other.allAssetsInDatabase, allAssetsInDatabase) &&
|
||||
other.progressInPercentage == progressInPercentage &&
|
||||
other.progressInFileSize == progressInFileSize &&
|
||||
other.progressInFileSpeed == progressInFileSpeed &&
|
||||
collectionEquals(other.progressInFileSpeeds, progressInFileSpeeds) &&
|
||||
other.progressInFileSpeedUpdateTime == progressInFileSpeedUpdateTime &&
|
||||
other.progressInFileSpeedUpdateSentBytes == progressInFileSpeedUpdateSentBytes &&
|
||||
other.iCloudDownloadProgress == iCloudDownloadProgress &&
|
||||
other.serverInfo == serverInfo &&
|
||||
other.autoBackup == autoBackup &&
|
||||
other.backgroundBackup == backgroundBackup &&
|
||||
other.backupRequireWifi == backupRequireWifi &&
|
||||
other.backupRequireCharging == backupRequireCharging &&
|
||||
other.backupTriggerDelay == backupTriggerDelay &&
|
||||
collectionEquals(other.availableAlbums, availableAlbums) &&
|
||||
collectionEquals(other.selectedBackupAlbums, selectedBackupAlbums) &&
|
||||
collectionEquals(other.excludedBackupAlbums, excludedBackupAlbums) &&
|
||||
collectionEquals(other.allUniqueAssets, allUniqueAssets) &&
|
||||
collectionEquals(other.selectedAlbumsBackupAssetsIds, selectedAlbumsBackupAssetsIds) &&
|
||||
other.currentUploadAsset == currentUploadAsset;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return backupProgress.hashCode ^
|
||||
allAssetsInDatabase.hashCode ^
|
||||
progressInPercentage.hashCode ^
|
||||
progressInFileSize.hashCode ^
|
||||
progressInFileSpeed.hashCode ^
|
||||
progressInFileSpeeds.hashCode ^
|
||||
progressInFileSpeedUpdateTime.hashCode ^
|
||||
progressInFileSpeedUpdateSentBytes.hashCode ^
|
||||
iCloudDownloadProgress.hashCode ^
|
||||
serverInfo.hashCode ^
|
||||
autoBackup.hashCode ^
|
||||
backgroundBackup.hashCode ^
|
||||
backupRequireWifi.hashCode ^
|
||||
backupRequireCharging.hashCode ^
|
||||
backupTriggerDelay.hashCode ^
|
||||
availableAlbums.hashCode ^
|
||||
selectedBackupAlbums.hashCode ^
|
||||
excludedBackupAlbums.hashCode ^
|
||||
allUniqueAssets.hashCode ^
|
||||
selectedAlbumsBackupAssetsIds.hashCode ^
|
||||
currentUploadAsset.hashCode;
|
||||
}
|
||||
}
|
||||
@ -1,95 +0,0 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'dart:convert';
|
||||
|
||||
class CurrentUploadAsset {
|
||||
final String id;
|
||||
final DateTime fileCreatedAt;
|
||||
final String fileName;
|
||||
final String fileType;
|
||||
final int? fileSize;
|
||||
final bool? iCloudAsset;
|
||||
|
||||
const CurrentUploadAsset({
|
||||
required this.id,
|
||||
required this.fileCreatedAt,
|
||||
required this.fileName,
|
||||
required this.fileType,
|
||||
this.fileSize,
|
||||
this.iCloudAsset,
|
||||
});
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
bool get isIcloudAsset => iCloudAsset != null && iCloudAsset!;
|
||||
|
||||
CurrentUploadAsset copyWith({
|
||||
String? id,
|
||||
DateTime? fileCreatedAt,
|
||||
String? fileName,
|
||||
String? fileType,
|
||||
int? fileSize,
|
||||
bool? iCloudAsset,
|
||||
}) {
|
||||
return CurrentUploadAsset(
|
||||
id: id ?? this.id,
|
||||
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
|
||||
fileName: fileName ?? this.fileName,
|
||||
fileType: fileType ?? this.fileType,
|
||||
fileSize: fileSize ?? this.fileSize,
|
||||
iCloudAsset: iCloudAsset ?? this.iCloudAsset,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
'id': id,
|
||||
'fileCreatedAt': fileCreatedAt.millisecondsSinceEpoch,
|
||||
'fileName': fileName,
|
||||
'fileType': fileType,
|
||||
'fileSize': fileSize,
|
||||
'iCloudAsset': iCloudAsset,
|
||||
};
|
||||
}
|
||||
|
||||
factory CurrentUploadAsset.fromMap(Map<String, dynamic> map) {
|
||||
return CurrentUploadAsset(
|
||||
id: map['id'] as String,
|
||||
fileCreatedAt: DateTime.fromMillisecondsSinceEpoch(map['fileCreatedAt'] as int),
|
||||
fileName: map['fileName'] as String,
|
||||
fileType: map['fileType'] as String,
|
||||
fileSize: map['fileSize'] as int,
|
||||
iCloudAsset: map['iCloudAsset'] != null ? map['iCloudAsset'] as bool : null,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory CurrentUploadAsset.fromJson(String source) =>
|
||||
CurrentUploadAsset.fromMap(json.decode(source) as Map<String, dynamic>);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CurrentUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType, fileSize: $fileSize, iCloudAsset: $iCloudAsset)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(covariant CurrentUploadAsset other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other.id == id &&
|
||||
other.fileCreatedAt == fileCreatedAt &&
|
||||
other.fileName == fileName &&
|
||||
other.fileType == fileType &&
|
||||
other.fileSize == fileSize &&
|
||||
other.iCloudAsset == iCloudAsset;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
fileCreatedAt.hashCode ^
|
||||
fileName.hashCode ^
|
||||
fileType.hashCode ^
|
||||
fileSize.hashCode ^
|
||||
iCloudAsset.hashCode;
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
|
||||
class ErrorUploadAsset {
|
||||
final String id;
|
||||
final DateTime fileCreatedAt;
|
||||
final String fileName;
|
||||
final String fileType;
|
||||
final Asset asset;
|
||||
final String errorMessage;
|
||||
|
||||
const ErrorUploadAsset({
|
||||
required this.id,
|
||||
required this.fileCreatedAt,
|
||||
required this.fileName,
|
||||
required this.fileType,
|
||||
required this.asset,
|
||||
required this.errorMessage,
|
||||
});
|
||||
|
||||
ErrorUploadAsset copyWith({
|
||||
String? id,
|
||||
DateTime? fileCreatedAt,
|
||||
String? fileName,
|
||||
String? fileType,
|
||||
Asset? asset,
|
||||
String? errorMessage,
|
||||
}) {
|
||||
return ErrorUploadAsset(
|
||||
id: id ?? this.id,
|
||||
fileCreatedAt: fileCreatedAt ?? this.fileCreatedAt,
|
||||
fileName: fileName ?? this.fileName,
|
||||
fileType: fileType ?? this.fileType,
|
||||
asset: asset ?? this.asset,
|
||||
errorMessage: errorMessage ?? this.errorMessage,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ErrorUploadAsset(id: $id, fileCreatedAt: $fileCreatedAt, fileName: $fileName, fileType: $fileType, asset: $asset, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ErrorUploadAsset &&
|
||||
other.id == id &&
|
||||
other.fileCreatedAt == fileCreatedAt &&
|
||||
other.fileName == fileName &&
|
||||
other.fileType == fileType &&
|
||||
other.asset == asset &&
|
||||
other.errorMessage == errorMessage;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
fileCreatedAt.hashCode ^
|
||||
fileName.hashCode ^
|
||||
fileType.hashCode ^
|
||||
asset.hashCode ^
|
||||
errorMessage.hashCode;
|
||||
}
|
||||
}
|
||||
@ -1,102 +0,0 @@
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:immich_mobile/models/backup/current_upload_asset.model.dart';
|
||||
|
||||
class ManualUploadState {
|
||||
// Current Backup Asset
|
||||
final CurrentUploadAsset currentUploadAsset;
|
||||
final int currentAssetIndex;
|
||||
|
||||
final bool showDetailedNotification;
|
||||
|
||||
/// Manual Upload Stats
|
||||
final int totalAssetsToUpload;
|
||||
final int successfulUploads;
|
||||
final double progressInPercentage;
|
||||
final String progressInFileSize;
|
||||
final double progressInFileSpeed;
|
||||
final List<double> progressInFileSpeeds;
|
||||
final DateTime progressInFileSpeedUpdateTime;
|
||||
final int progressInFileSpeedUpdateSentBytes;
|
||||
|
||||
const ManualUploadState({
|
||||
required this.progressInPercentage,
|
||||
required this.progressInFileSize,
|
||||
required this.progressInFileSpeed,
|
||||
required this.progressInFileSpeeds,
|
||||
required this.progressInFileSpeedUpdateTime,
|
||||
required this.progressInFileSpeedUpdateSentBytes,
|
||||
required this.currentUploadAsset,
|
||||
required this.totalAssetsToUpload,
|
||||
required this.currentAssetIndex,
|
||||
required this.successfulUploads,
|
||||
required this.showDetailedNotification,
|
||||
});
|
||||
|
||||
ManualUploadState copyWith({
|
||||
double? progressInPercentage,
|
||||
String? progressInFileSize,
|
||||
double? progressInFileSpeed,
|
||||
List<double>? progressInFileSpeeds,
|
||||
DateTime? progressInFileSpeedUpdateTime,
|
||||
int? progressInFileSpeedUpdateSentBytes,
|
||||
CurrentUploadAsset? currentUploadAsset,
|
||||
int? totalAssetsToUpload,
|
||||
int? successfulUploads,
|
||||
int? currentAssetIndex,
|
||||
bool? showDetailedNotification,
|
||||
}) {
|
||||
return ManualUploadState(
|
||||
progressInPercentage: progressInPercentage ?? this.progressInPercentage,
|
||||
progressInFileSize: progressInFileSize ?? this.progressInFileSize,
|
||||
progressInFileSpeed: progressInFileSpeed ?? this.progressInFileSpeed,
|
||||
progressInFileSpeeds: progressInFileSpeeds ?? this.progressInFileSpeeds,
|
||||
progressInFileSpeedUpdateTime: progressInFileSpeedUpdateTime ?? this.progressInFileSpeedUpdateTime,
|
||||
progressInFileSpeedUpdateSentBytes: progressInFileSpeedUpdateSentBytes ?? this.progressInFileSpeedUpdateSentBytes,
|
||||
currentUploadAsset: currentUploadAsset ?? this.currentUploadAsset,
|
||||
totalAssetsToUpload: totalAssetsToUpload ?? this.totalAssetsToUpload,
|
||||
currentAssetIndex: currentAssetIndex ?? this.currentAssetIndex,
|
||||
successfulUploads: successfulUploads ?? this.successfulUploads,
|
||||
showDetailedNotification: showDetailedNotification ?? this.showDetailedNotification,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ManualUploadState(progressInPercentage: $progressInPercentage, progressInFileSize: $progressInFileSize, progressInFileSpeed: $progressInFileSpeed, progressInFileSpeeds: $progressInFileSpeeds, progressInFileSpeedUpdateTime: $progressInFileSpeedUpdateTime, progressInFileSpeedUpdateSentBytes: $progressInFileSpeedUpdateSentBytes, currentUploadAsset: $currentUploadAsset, totalAssetsToUpload: $totalAssetsToUpload, successfulUploads: $successfulUploads, currentAssetIndex: $currentAssetIndex, showDetailedNotification: $showDetailedNotification)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
final collectionEquals = const DeepCollectionEquality().equals;
|
||||
|
||||
return other is ManualUploadState &&
|
||||
other.progressInPercentage == progressInPercentage &&
|
||||
other.progressInFileSize == progressInFileSize &&
|
||||
other.progressInFileSpeed == progressInFileSpeed &&
|
||||
collectionEquals(other.progressInFileSpeeds, progressInFileSpeeds) &&
|
||||
other.progressInFileSpeedUpdateTime == progressInFileSpeedUpdateTime &&
|
||||
other.progressInFileSpeedUpdateSentBytes == progressInFileSpeedUpdateSentBytes &&
|
||||
other.currentUploadAsset == currentUploadAsset &&
|
||||
other.totalAssetsToUpload == totalAssetsToUpload &&
|
||||
other.currentAssetIndex == currentAssetIndex &&
|
||||
other.successfulUploads == successfulUploads &&
|
||||
other.showDetailedNotification == showDetailedNotification;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return progressInPercentage.hashCode ^
|
||||
progressInFileSize.hashCode ^
|
||||
progressInFileSpeed.hashCode ^
|
||||
progressInFileSpeeds.hashCode ^
|
||||
progressInFileSpeedUpdateTime.hashCode ^
|
||||
progressInFileSpeedUpdateSentBytes.hashCode ^
|
||||
currentUploadAsset.hashCode ^
|
||||
totalAssetsToUpload.hashCode ^
|
||||
currentAssetIndex.hashCode ^
|
||||
successfulUploads.hashCode ^
|
||||
showDetailedNotification.hashCode;
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
import 'package:immich_mobile/models/backup/backup_candidate.model.dart';
|
||||
|
||||
class SuccessUploadAsset {
|
||||
final BackupCandidate candidate;
|
||||
final String remoteAssetId;
|
||||
final bool isDuplicate;
|
||||
|
||||
const SuccessUploadAsset({required this.candidate, required this.remoteAssetId, required this.isDuplicate});
|
||||
|
||||
SuccessUploadAsset copyWith({BackupCandidate? candidate, String? remoteAssetId, bool? isDuplicate}) {
|
||||
return SuccessUploadAsset(
|
||||
candidate: candidate ?? this.candidate,
|
||||
remoteAssetId: remoteAssetId ?? this.remoteAssetId,
|
||||
isDuplicate: isDuplicate ?? this.isDuplicate,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'SuccessUploadAsset(asset: $candidate, remoteAssetId: $remoteAssetId, isDuplicate: $isDuplicate)';
|
||||
|
||||
@override
|
||||
bool operator ==(covariant SuccessUploadAsset other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other.candidate == candidate && other.remoteAssetId == remoteAssetId && other.isDuplicate == isDuplicate;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => candidate.hashCode ^ remoteAssetId.hashCode ^ isDuplicate.hashCode;
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
|
||||
class Memory {
|
||||
final String title;
|
||||
final List<Asset> assets;
|
||||
const Memory({required this.title, required this.assets});
|
||||
|
||||
Memory copyWith({String? title, List<Asset>? assets}) {
|
||||
return Memory(title: title ?? this.title, assets: assets ?? this.assets);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'Memory(title: $title, assets: $assets)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
final listEquals = const DeepCollectionEquality().equals;
|
||||
|
||||
return other is Memory && other.title == title && listEquals(other.assets, assets);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => title.hashCode ^ assets.hashCode;
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/person.model.dart';
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
|
||||
class SearchLocationFilter {
|
||||
String? country;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user