תוכן יוסי גריינימן - HWzone פורומים
עבור לתוכן
  • צור חשבון

יוסי גריינימן

משתמש רשום
  • מספר הודעות

    1
  • הצטרפות

  • ביקר לאחרונה

הודעות שנפתחו על-ידי יוסי גריינימן

  1.  

     

    1681919168052-0e7dd27b-77a7-41ac-9efe-a4aa610b644b-image.png.f10bf53a59d7187a8fa2671ba0648d9e.png

     

     

    1681919241489-07f6ee50-501b-4fa8-9f48-82c83db1a053-image.png.611069168f902b0a650658afb083fbd1.png

     

    וכל זה ב7-8 הכי הרבה 10

    //servise אנגולר
    import {Injectable} from '@angular/core';
    import {AngularFirestore} from '@angular/fire/compat/firestore';
    import {catchError} from 'rxjs/operators';
    import {throwError} from 'rxjs';
    
    @Injectable({
      providedIn: 'root'
    })
    export class DataService
    {
      videos: any[] = []
      errorVideos: any = false
      users: any = false
    
      constructor (private firestore: AngularFirestore)
      {
        this.getvideos();
      }
    
      getvideos ()
      {
    
        if (this.videos.length === 0 && !this.errorVideos)
        {
          this.firestore.collection('videos')
            .valueChanges()
            .pipe(
              catchError(error =>
              {
                this.errorVideos = {
                  text: error.message
                }
                if (localStorage.getItem('videos') != null)
                {
                  let string: any = localStorage.getItem('videos')
    
                  this.videos = JSON.parse(string)
    
                  this.errorVideos.timevideos = localStorage.getItem('timevideos')
    
                  console.log(this.videos)
                }
                return throwError(error);
              })
            )
            .subscribe(data =>
            {
              this.videos = data;
    
              console.log(this.videos)
    
              let string = JSON.stringify(this.videos)
              localStorage.setItem('videos', string)
              localStorage.setItem('timevideos', '' + new Date().getTime())
            });
        }
      }
    }

    ובמילים פשוטות בconstrctor(בנאי מופעל ברגע הראשון)
    יש קריאה ל
    this.getvideos();
    ששולח קריאה לfirebase לקבל את כל הcollection
    ( this.firestore.collection('videos')
    .valueChanges())
    ולשמור אותו במשתנה videos וכל זה רק במקרה שעדיין הוא ריק (כי יש כמה מקומות שמשתמשים בservise הזה)
    (כל מה שלפני הsubscribe זה טיפול בשגיאות)

    מספר פעמים רעננתי את הדף (כי הרי הוא לא יקרא לנתונים פעמים באותו כניסה)
    ואחרי מספר פעמים
    התמונות למעלה

    תגובת הקונסול
    ROR FirebaseError: Quota exceeded.
    h

    בקולקשן (collection) videos יש 3579 אובייקטים שמכילים

    date סטרינג
    id סטרינג
    img אוביקט עם url , אורך ורוחב כולם סטירינג (רוחב ואורך מספר)
    name סטרינג
    text סטרינג
    userid סטרינג

    אבל בfirebase זה נראה כאילו קראתי יותר מ50000 (50k) פעם
    יכול להיות שזה לפי אוביקט ולא לפי קריאה ?

×
  • צור חדש...