Browse Source

Fix spoiler link click

Fix attaching preloader to video
Fix displaying chat avatars
Fix contextmenu color in popups
master
Eduard Kuzmenko 2 years ago
parent
commit
3144026fba
  1. 26
      src/components/appMediaViewerBase.ts
  2. 3
      src/lib/appManagers/appDownloadManager.ts
  3. 8
      src/lib/appManagers/appManagersManager.ts
  4. 8
      src/lib/appManagers/appMessagesManager.ts
  5. 24
      src/lib/appManagers/createManagers.ts
  6. 5
      src/lib/appManagers/manager.ts
  7. 1
      src/lib/mtproto/apiFileManager.ts
  8. 4
      src/lib/mtproto/apiManager.ts
  9. 2
      src/lib/storages/peers.ts
  10. 4
      src/scss/partials/_spoiler.scss
  11. 3
      src/scss/style.scss

26
src/components/appMediaViewerBase.ts

@ -1374,16 +1374,6 @@ export default class AppMediaViewerBase<
} }
}); });
video.addEventListener('error', () => {
if(video.error.code !== 4) {
this.log.error("Error " + video.error.code + "; details: " + video.error.message);
}
if(preloader) {
preloader.detach();
}
}, {once: true});
this.addEventListener('setMoverAfter', () => { this.addEventListener('setMoverAfter', () => {
video.src = ''; video.src = '';
video.load(); video.load();
@ -1491,6 +1481,7 @@ export default class AppMediaViewerBase<
if(supportsStreaming) { if(supportsStreaming) {
onAnimationEnd.then(() => { onAnimationEnd.then(() => {
if(video.readyState < video.HAVE_FUTURE_DATA) { if(video.readyState < video.HAVE_FUTURE_DATA) {
console.log('ppp 1');
preloader.attach(mover, true); preloader.attach(mover, true);
} }
@ -1501,7 +1492,7 @@ export default class AppMediaViewerBase<
const attachCanPlay = () => { const attachCanPlay = () => {
video.addEventListener('canplay', () => { video.addEventListener('canplay', () => {
//this.log('video waited and progress loaded'); console.log('ppp 2');
preloader.detach(); preloader.detach();
video.parentElement.classList.remove('is-buffering'); video.parentElement.classList.remove('is-buffering');
}, {once: true}); }, {once: true});
@ -1515,6 +1506,7 @@ export default class AppMediaViewerBase<
if(loading && isntEnoughData) { if(loading && isntEnoughData) {
attachCanPlay(); attachCanPlay();
console.log('ppp 3');
preloader.attach(mover, true); preloader.attach(mover, true);
// поставлю класс для плеера, чтобы убрать большую иконку пока прелоадер на месте // поставлю класс для плеера, чтобы убрать большую иконку пока прелоадер на месте
@ -1542,6 +1534,7 @@ export default class AppMediaViewerBase<
if(!supportsStreaming) { if(!supportsStreaming) {
onAnimationEnd.then(async() => { onAnimationEnd.then(async() => {
if(!(await getCacheContext()).url) { if(!(await getCacheContext()).url) {
console.log('ppp 4');
preloader.attach(mover, true, promise); preloader.attach(mover, true, promise);
} }
}); });
@ -1554,6 +1547,17 @@ export default class AppMediaViewerBase<
} }
const url = (await getCacheContext()).url; const url = (await getCacheContext()).url;
video.addEventListener('error', () => {
if(video.error.code !== 4) {
this.log.error("Error " + video.error.code + "; details: " + video.error.message);
}
if(preloader) {
preloader.detach();
}
}, {once: true});
if(target instanceof SVGSVGElement/* && (video.parentElement || !isSafari) */) { // if video exists if(target instanceof SVGSVGElement/* && (video.parentElement || !isSafari) */) { // if video exists
//if(!video.parentElement) { //if(!video.parentElement) {
div.firstElementChild.lastElementChild.append(video); div.firstElementChild.lastElementChild.append(video);

3
src/lib/appManagers/appDownloadManager.ts

@ -159,9 +159,6 @@ export class AppDownloadManager {
public downloadMedia(options: DownloadMediaOptions, type: DownloadType = 'blob'): DownloadBlob { public downloadMedia(options: DownloadMediaOptions, type: DownloadType = 'blob'): DownloadBlob {
const {downloadOptions, fileName} = getDownloadMediaDetails(options); const {downloadOptions, fileName} = getDownloadMediaDetails(options);
if(fileName === 'document_5307720352468571676') {
debugger;
}
return this.d(fileName, () => { return this.d(fileName, () => {
const cb = type === 'url' ? this.managers.apiFileManager.downloadMediaURL : (type === 'void' ? this.managers.apiFileManager.downloadMediaVoid : this.managers.apiFileManager.downloadMedia); const cb = type === 'url' ? this.managers.apiFileManager.downloadMediaURL : (type === 'void' ? this.managers.apiFileManager.downloadMediaVoid : this.managers.apiFileManager.downloadMedia);

8
src/lib/appManagers/appManagersManager.ts

@ -58,13 +58,7 @@ export class AppManagersManager {
this.cryptoPortPromise this.cryptoPortPromise
]); ]);
const managers = await createManagers(appStoragesManager); const managers = await createManagers(appStoragesManager, appStateManager.userId);
// костыль
if(appStateManager.userId) {
managers.apiManager.setUserAuth(appStateManager.userId);
}
return this.managers = managers; return this.managers = managers;
} }

8
src/lib/appManagers/appMessagesManager.ts

@ -2634,7 +2634,9 @@ export class AppMessagesManager extends AppManager {
message.reply_to.reply_to_msg_id = message.reply_to_mid = generateMessageId(message.reply_to.reply_to_msg_id); message.reply_to.reply_to_msg_id = message.reply_to_mid = generateMessageId(message.reply_to.reply_to_msg_id);
} }
if(message.reply_to.reply_to_top_id) message.reply_to.reply_to_top_id = generateMessageId(message.reply_to.reply_to_top_id); if(message.reply_to.reply_to_top_id) {
message.reply_to.reply_to_top_id = generateMessageId(message.reply_to.reply_to_top_id);
}
} }
const replies = isMessage && message.replies; const replies = isMessage && message.replies;
@ -2649,9 +2651,9 @@ export class AppMessagesManager extends AppManager {
} }
//storage.generateIndex(message); //storage.generateIndex(message);
const myId = this.appUsersManager.getSelf().id.toPeerId(); const myId = this.appPeersManager.peerId;
const fwdHeader = isMessage && (message as Message.message).fwd_from as MessageFwdHeader; const fwdHeader = isMessage && (message as Message.message).fwd_from;
message.peerId = peerId; message.peerId = peerId;
if(peerId === myId/* && !message.from_id && !message.fwd_from */) { if(peerId === myId/* && !message.from_id && !message.fwd_from */) {

24
src/lib/appManagers/createManagers.ts

@ -42,8 +42,9 @@ import { TimeManager } from "../mtproto/timeManager";
import { AppStoragesManager } from "./appStoragesManager"; import { AppStoragesManager } from "./appStoragesManager";
import cryptoMessagePort from "../crypto/cryptoMessagePort"; import cryptoMessagePort from "../crypto/cryptoMessagePort";
import appStateManager from "./appStateManager"; import appStateManager from "./appStateManager";
import filterUnique from "../../helpers/array/filterUnique";
export default function createManagers(appStoragesManager: AppStoragesManager) { export default function createManagers(appStoragesManager: AppStoragesManager, userId: UserId) {
const managers = { const managers = {
appPeersManager: new AppPeersManager, appPeersManager: new AppPeersManager,
appChatsManager: new AppChatsManager, appChatsManager: new AppChatsManager,
@ -101,13 +102,26 @@ export default function createManagers(appStoragesManager: AppStoragesManager) {
ctx[name] = manager; ctx[name] = manager;
} }
const promises: Array<Promise<any> | void>[] = []; if(userId) {
for(const name in managers) { managers.apiManager.setUserAuth(userId);
const manager = managers[name as keyof T]; }
const promises: Array<Promise<(() => void) | void> | void>[] = [];
let names = Object.keys(managers) as (keyof T)[];
names.unshift('appUsersManager', 'appChatsManager', 'appMessagesManager', 'dialogsStorage');
names = filterUnique(names);
for(const name of names) {
const manager = managers[name];
if((manager as any)?.after) { if((manager as any)?.after) {
// console.log('injecting after', name);
const result = (manager as any).after(); const result = (manager as any).after();
promises.push(result); promises.push(result);
delete (manager as any).after;
// if(result instanceof Promise) {
// result.then(() => {
// console.log('injected after', name);
// });
// }
} }
} }

5
src/lib/appManagers/manager.ts

@ -89,9 +89,4 @@ export class AppManager {
Object.assign(this, managers); Object.assign(this, managers);
// this.after(); // this.after();
} }
protected after(): Promise<void> | void {
}
} }

1
src/lib/mtproto/apiFileManager.ts

@ -33,6 +33,7 @@ import getFileNameForUpload from "../../helpers/getFileNameForUpload";
import type { Progress } from "../appManagers/appDownloadManager"; import type { Progress } from "../appManagers/appDownloadManager";
import getDownloadMediaDetails from "../appManagers/utils/download/getDownloadMediaDetails"; import getDownloadMediaDetails from "../appManagers/utils/download/getDownloadMediaDetails";
import networkStats from "./networkStats"; import networkStats from "./networkStats";
import pause from "../../helpers/schedulers/pause";
type Delayed = { type Delayed = {
offset: number, offset: number,

4
src/lib/mtproto/apiManager.ts

@ -242,6 +242,8 @@ export class ApiManager extends ApiManagerMethods {
userAuth = {dcID: 0, date: Date.now() / 1000 | 0, id: userAuth.toPeerId(false)}; userAuth = {dcID: 0, date: Date.now() / 1000 | 0, id: userAuth.toPeerId(false)};
} }
this.rootScope.dispatchEvent('user_auth', userAuth);
if(!userAuth.dcID) { if(!userAuth.dcID) {
const baseDcId = await this.getBaseDcId(); const baseDcId = await this.getBaseDcId();
userAuth.dcID = baseDcId; userAuth.dcID = baseDcId;
@ -252,8 +254,6 @@ export class ApiManager extends ApiManagerMethods {
}); });
//this.telegramMeNotify(true); //this.telegramMeNotify(true);
this.rootScope.dispatchEvent('user_auth', userAuth);
} }
public setBaseDcId(dcId: DcId) { public setBaseDcId(dcId: DcId) {

2
src/lib/storages/peers.ts

@ -22,7 +22,7 @@ class PeersStorage {
protected after() { protected after() {
this.rootScope.addEventListener('user_auth', () => { this.rootScope.addEventListener('user_auth', () => {
this.requestPeer(this.appUsersManager.userId.toPeerId(), 'self'); this.requestPeer(this.appPeersManager.peerId, 'self');
}); });
} }

4
src/scss/partials/_spoiler.scss

@ -67,6 +67,10 @@
&:not(.is-spoiler-visible) { &:not(.is-spoiler-visible) {
.spoiler { .spoiler {
cursor: pointer; cursor: pointer;
&-text {
pointer-events: none;
}
} }
} }
} }

3
src/scss/style.scss

@ -94,7 +94,6 @@ $chat-input-inner-padding-handhelds: .25rem;
--disabled-opacity: .3; --disabled-opacity: .3;
--round-video-size: 280px; --round-video-size: 280px;
--menu-box-shadow: 0px 0px 10px var(--menu-box-shadow-color); --menu-box-shadow: 0px 0px 10px var(--menu-box-shadow-color);
--menu-background-color: rgba(var(--surface-color-rgb), .75);
--menu-backdrop-filter: blur(50px); --menu-backdrop-filter: blur(50px);
--font-monospace: 'Roboto Mono', monospace; --font-monospace: 'Roboto Mono', monospace;
--font-weight-bold: 500; --font-weight-bold: 500;
@ -208,6 +207,7 @@ $chat-input-inner-padding-handhelds: .25rem;
--spoiler-background-color: #e3e5e8; --spoiler-background-color: #e3e5e8;
--spoiler-draft-background-color: #d9d9d9; --spoiler-draft-background-color: #d9d9d9;
--monospace-text-color: var(--danger-color); --monospace-text-color: var(--danger-color);
--menu-background-color: rgba(var(--surface-color-rgb), .75);
--message-background-color: var(--surface-color); --message-background-color: var(--surface-color);
--message-checkbox-color: #61c642; --message-checkbox-color: #61c642;
@ -281,6 +281,7 @@ $chat-input-inner-padding-handhelds: .25rem;
--spoiler-background-color: #373e4e; --spoiler-background-color: #373e4e;
--spoiler-draft-background-color: #484848; --spoiler-draft-background-color: #484848;
--monospace-text-color: var(--primary-text-color); --monospace-text-color: var(--primary-text-color);
--menu-background-color: rgba(var(--surface-color-rgb), .75);
--message-background-color: var(--surface-color); --message-background-color: var(--surface-color);
--message-checkbox-color: var(--primary-color); --message-checkbox-color: var(--primary-color);

Loading…
Cancel
Save